Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method 'Cells' of Object _Global failed

Status
Not open for further replies.

siris

Programmer
Aug 13, 2004
10
IN
that is what I get when I execute the following line to generate a graph through VBA.

ActiveChart.SetSourceData Source:=Sheets("2001 Data").Range(Cells(1, 1), Cells(currRow, 1)), PlotBy:=xlColumns

where currRow is the variable which stores the last row number, because I'm entering some values into the sheet from a sql db.

but if I hard code the last row number as below then it works fine. Why is the above error popping up????

ActiveChart.SetSourceData Source:=Sheets("2001 Data").Range("A1:C31"), PlotBy:=xlColumns
 
What have you declared "currRow" as? Have you tried executing the macro in break mode and examining the value of currRow in the Watch window to see how the value changes (particularly just before the macro falls down).

I don't normally use the Cells property, but from memory it's a global property with the args being row#,col# so I can't see any problem with that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top