#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default chats help

Hi all,

I am Using MS office 2003. I want to create chart using VBA. I have
written the folowing function.

Public Function AddChartSheet(ByVal x As Long, ByVal y As Long, ByVal z
As Long)
Sheet1.Activate
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheet1.Range(Cells(z + 1, 2),
Cells(x - 1, y - 1)), PlotBy:= _
xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet
End Function

and calling this function in my main program. But I am geeting and
error "Method of cells of object _Global Failed".

Can any one suggest.

Regards,
Srinivas

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default chats help

Srinivas,

I haven't tested it but I would guess that you need to qualify the cells
reference, since you have added a chart sheet (which does not have cells).

Try this
ActiveChart.SetSourceData Source:=Sheet1.Range(Sheet1.Cells(z + 1,
2),Sheet1.Cells(x - 1, y - 1)), etc...

Robin Hammond
www.enhanceddatasystems.com


"srinivas" wrote in message
oups.com...
Hi all,

I am Using MS office 2003. I want to create chart using VBA. I have
written the folowing function.

Public Function AddChartSheet(ByVal x As Long, ByVal y As Long, ByVal z
As Long)
Sheet1.Activate
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheet1.Range(Cells(z + 1, 2),
Cells(x - 1, y - 1)), PlotBy:= _
xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet
End Function

and calling this function in my main program. But I am geeting and
error "Method of cells of object _Global Failed".

Can any one suggest.

Regards,
Srinivas



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default chats help

Srinivas,
When you add the chart, it becomes the active sheet.
"Cells" refers to the active sheet.
Add "Sheet1." in front of "Cells" (two places).
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"srinivas"

wrote in message
Hi all,
I am Using MS office 2003. I want to create chart using VBA. I have
written the folowing function.

Public Function AddChartSheet(ByVal x As Long, ByVal y As Long, _
ByVal z As Long)
Sheet1.Activate
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheet1.Range(Cells(z + 1, 2),
Cells(x - 1, y - 1)), PlotBy:= _
xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet
End Function

and calling this function in my main program. But I am geeting and
error "Method of cells of object _Global Failed".
Can any one suggest.
Regards,
Srinivas

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 chats slow to a crawl KenT Charts and Charting in Excel 0 August 27th 07 03:30 AM
copy excel chats I dont stand Excel to Chat... Charts and Charting in Excel 0 June 11th 05 01:42 PM
Blood Pressure Chats in Excell Gwen Charts and Charting in Excel 0 June 9th 05 08:24 AM
Excel doesn't add up Pie Chats correctly Peter Thorn Excel Discussion (Misc queries) 1 March 24th 05 12:17 PM


All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"