Option Explicit
Option Base 1
Dim vArray(2, 6) As Variant
Private Sub Form_Load()
Dim i, j
For i = 1 To 2
For j = 1 To 6
vArray(i, j) = Int((Rnd(10) + Rnd(10) * 10) * 10)
Next j
Next i
Command1.Caption = "SetData Method"
Check1.Caption = "Null Data Point"
Check1.Value = vbChecked
End Sub
Private Sub Command1_Click()
Dim intCount As Integer, dataflag As Boolean
Dim column As Integer, row As Integer, anumber As Variant
If Check1.Value = vbChecked Then
vArray(1, 4) = vbNull
Else
vArray(1, 4) = 0
End If
With MSChart1
.chartType = VtChChartType2dLine
.ColumnCount = 2
.RowCount = 6
For column = 1 To .ColumnCount
For row = 1 To .RowCount
If (vArray(column, row)) <> vbNull Then
dataflag = False
Else
dataflag = True
End If
.DataGrid.SetData row, column, _
vArray(column, row), _
dataflag
Next row
Next column
With .DataGrid
.ColumnLabelCount = 1
.ColumnLabel(1, 1) = "abc"
.ColumnLabel(2, 1) = "xyz"
.RowLabelCount = 1
.RowLabel(1, 1) = "Jan"
.RowLabel(2, 1) = "Feb"
.RowLabel(3, 1) = "Mar"
.RowLabel(4, 1) = "Apr"
.RowLabel(5, 1) = "May"
.RowLabel(6, 1) = "Jun"
End With
.ShowLegend = True
End With
End Sub