owc chartspace에 약간의 문제가 있습니다. 그림과 같은 차트를 그리지 만 문제는 그려야 할 시리즈 하나에 대해서만 그립니다. 그것은 1과 2, 3을 위해 어떻게 해야할지 모르겠습니다.userform vba에서 owc chartspace를 사용하여 차트 그리기
나는 목록 상자와 콤보 박스를 가지고 있는데, 나는 목록 상자에서 1,2,3을 선택하고 콤보 x 또는 z 중에서 x가 고정되도록 선택한다.
그런 다음 y에 대해 plage (1) 및 plage (2)에 데이터를 넣었지만 문제는 목록 상자에서 선택한 첫 번째 항목 (이 그림에서 "1")에만 적용된다는 것입니다.
내 코드에서 무엇이 잘못되었는지 말할 수 있습니까?
정의 폼에 차트를 그리기위한 VBA 코드는 다음과 같습니다
Private Sub drow()
Dim i, k As Integer, x As Integer
Dim j As Integer
Dim Table(), Plage(2)
Dim id As Integer
id = 1
Do While ComboBox.Value <> idi(id, 1)
id = id + 1
Loop
For i = Cht.SeriesCollection.Count To 1 Step -1
Cht.SeriesCollection.Delete i - 1
Next i
k = 1
ReDim Table(ListBox.ListCount)
For i = 0 To ListBox.ListCount - 1
If ListBox.Selected(i) = True Then
Table(k) = ListBox.List(i)
k = k + 1
End If
Next i
With Cht
.HasLegend = True
.Legend.Position = chLegendPositionBottom
.HasTitle = True
.Title.Caption = ComboBox.Text
End With
Cht.Type = C.chChartTypeColumnClustered3D
With Cht
'first serie
.SeriesCollection.Add
.SeriesCollection(0).Caption = sheet.Cells(2, 15 + id)
.SeriesCollection(0).DataLabelsCollection.Add
.SeriesCollection(0).DataLabelsCollection(0).Position = chLabelPositionCenter
.SeriesCollection(0).DataLabelsCollection(0).Font.Color = RGB(255, 255, 255)
.SeriesCollection.Add
.SeriesCollection(1).Caption = sheet.Cells(2, 20) .SeriesCollection(1).DataLabelsCollection.Add
.SeriesCollection(1).DataLabelsCollection(0).Position = chLabelPositionCenter
.SeriesCollection(1).DataLabelsCollection(0).Font.Color = RGB(255, 255, 255)
.SetData C1.chDimCategories, C1.chDataLiteral, Table
End With
For j = 0 To ListBox.ListCount - 1
If ListBox.Selected(j) = True Then
Plage(1) = sheet.Cells(j + 3, 15 + id) 'the Xs
Plage(2) = sheet.Cells(j + 3, 20) 'Les 'the Ys
With Cht
.SeriesCollection(0).SetData C1.chDimValues, C1.chDataLiteral, Plage(1)
.SeriesCollection(1).SetData C1.chDimValues, C1.chDataLiteral, Plage(2)
End With
Erase Plage
End If
Next j
End Sub
누구나 어떤 생각을 가지고 있습니까 ???????? – Eddinho