Charts in VBA

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Delete a chart 4
positioning charts 3
Chart Size & Position 3
Loop to create charts 1
Excel Macro for Charts 1
Excel Macro Help for Charts 8
How to make chart embedded in active sheet? 5
Dynamic chart problem 1

Top