I'm struggling for the last couple of hours with an error. I want to make a code that plots the same range for each sheet. When I add a series collection it fails. I have modified the code from a recorded macro, which works perfectly. This is the code in question:
Sub plot()
Dim wb As Excel.Workbook
Set wb = ThisWorkbook
Dim ws As Worksheet
Dim name As String
Dim plot As Excel.Shape
For Each ws In wb.Worksheets
name = ws.name
Set plot = ws.Shapes.AddChart
plot.Chart.ChartType = xlXYScatterLines'until here it works perfectly
plot.Chart.SeriesCollection(1).name = "=""something"""' on this line I get the error
Next
End Sub
And the error is:
Run - time error '1004':
Application-defined or object-defined error
And the help says that is an error from excel, not VBA, so it doesnt care... :) Any help will be much appreciated. Cheers!