I am trying to write a VBA that generate the plot on the ActiveSheet with the values from the cells F3, F6,F9,F12 of any spreadsheet. My codes are shown below.
Sub Column_Chart()
With ActiveSheet.Shapes.AddChart.Chart
.ChartType=xl3DColumn
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Name ="Series 1"
.Values = "=" & ActiveSheetName &"!" & _
Cells(3,6) "," & ActiveSheetName &"!" & _
Cells(6,6) "," & ActiveSheetName &"!" & _
Cells(9,6) "," & ActiveSheetName &"!" & _
Cells(12,6).Address
End With
End With
End Sub
It appears that there is an error of using comma "," within the codes for values, the error message is "Expected: End of Statement". I tried to remove the quotation mark but it still encounter the same error message. How can I indicate different specific cells as the values for the chart?
Sub Column_Chart()
With ActiveSheet.Shapes.AddChart.Chart
.ChartType=xl3DColumn
.SeriesCollection.NewSeries
With .SeriesCollection(1)
.Name ="Series 1"
.Values = "=" & ActiveSheetName &"!" & _
Cells(3,6) "," & ActiveSheetName &"!" & _
Cells(6,6) "," & ActiveSheetName &"!" & _
Cells(9,6) "," & ActiveSheetName &"!" & _
Cells(12,6).Address
End With
End With
End Sub
It appears that there is an error of using comma "," within the codes for values, the error message is "Expected: End of Statement". I tried to remove the quotation mark but it still encounter the same error message. How can I indicate different specific cells as the values for the chart?