chamster
09-12-2007, 08:11 AM
I'm running the following code and as far i can see, it should work. The computer disagrees and, unfortunately, it wins. Where do i go wrong?
Sub CreatePlot()
Dim chrt As Chart
Set chrt = Charts.Add
chrt.ChartType = xlXYScatter
chrt.SetSourceData Source:=Selection.CurrentRegion, PlotBy:=xlColumns
chrt.Location Where:=xlLocationAsObject, Name:="Kvalit?er"
chrt.HasLegend = False
End Sub
The strange part is that i get to see the graph, only as a separate sheet. So, it seems that the selection gives data to the plot. Still, it's on the line with .SetDataSource that i get the error. Something about 438: The object doesn't support method/property...
When i go back to Excel and manually set the active sheet to be the one with the data, it works through the line so i'm suspecting that the error should be somewhere there.
But then again, as i start to continue, i get errors at .HasLegend.
Sub CreatePlot()
Dim chrt As Chart
Set chrt = Charts.Add
chrt.ChartType = xlXYScatter
chrt.SetSourceData Source:=Selection.CurrentRegion, PlotBy:=xlColumns
chrt.Location Where:=xlLocationAsObject, Name:="Kvalit?er"
chrt.HasLegend = False
End Sub
The strange part is that i get to see the graph, only as a separate sheet. So, it seems that the selection gives data to the plot. Still, it's on the line with .SetDataSource that i get the error. Something about 438: The object doesn't support method/property...
When i go back to Excel and manually set the active sheet to be the one with the data, it works through the line so i'm suspecting that the error should be somewhere there.
But then again, as i start to continue, i get errors at .HasLegend.