Charts in VBA

  • Thread starter Thread starter Rui Álvares
  • Start date Start date
R

Rui Álvares

Hi,

I have the code shown below, that creates a chart based in the data present
in sheet "Sheet_1":

Charts.Add
ActiveChart.ChartType = xlXYScatterLinesNoMarkers
ActiveChart.SetSourceData Source:= _
Sheets("Sheet_1").Range("A1:B382"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Grafics"
With ActiveChart
 
You need to be sure you are using the proper Sheet Object
better change to this
with Sheets("Sheet_1")
.Range(.Cells(1, 1), .Cells(rowNum, 2)),
PlotBy:=xlColumns
end with


Beware of the point before the Cells methods, indicating that you are
refering to the same sheet.

Francisco mariscal
 
Back
Top