So, I have created an array, and I am trying to put the data into a chart... but I have no clue how to make the chart take on the data from an array I generated, rather than from a range. I coded for a chart uding a Range from an excel sheet.. but I can't see how to make all of that happen when I have this array..
I have two sub procedures. Inside one of them I want to use
And I will be calling on:
Sub ChartNew2()
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Range("D1:D30"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject
With ActiveChart
.HasTitle = True
.Axes(xlValue, xlPrimary).HasTitle = True
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
End With
ActiveChart.HasLegend = False
ActiveChart.PlotArea.Select
Selection.Interior.ColorIndex = xlAutomatic
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MaximumScale = 1
End With
End Sub
How can I do that? I tried in this way and I wasn't successful either...
Sub ChartNew2(result2 As Variant)
Dim i As Integer
ReDim result2(1 To 4, 1 To 1)
Charts.Add
For i = LBound(result2, 1) To UBound(result2, 1)
result2(i, 1) = result2
Next i
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.Location Where:=xlLocationAsObject
'For i = 1 To 4
' With ActiveChart.SeriesCollection(1)
' .XValues = result2(i)
' .Values = arrIntervals(i)
'End With
'Next i
With ActiveChart
.HasTitle = True
.Axes(xlValue, xlPrimary).HasTitle = True
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
End With
ActiveChart.HasLegend = False
ActiveChart.PlotArea.Select
Selection.Interior.ColorIndex = xlAutomatic
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MaximumScale = 1
End With
End Sub
Bookmarks