Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default charts fucntion help needed

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: 2,489
Default charts fucntion help needed

Hi,

You probably need to fully qualify the Cells object, especially if
Charts.add is creating a new chart sheet which does not have cells.

Cheers
Andy

srinivas wrote:
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


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default charts fucntion help needed

Hi Andy,

I got the answer. Thanks a lot for your help.

Public Function AddChartSheet(ByVal x As Long, ByVal y As Long, ByVal z
As Long)
Dim ws As Worksheet
Set ws = Worksheets(1)
Sheet1.Activate
'temp = Sheet1.Range(Cells(z + 1, 2), Cells(x - 1, y - 1))
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=ws.Range(ws.Cells(z + 1, 2),
ws.Cells(x - 1, y - 1)), PlotBy:= _
xlColumns
'ActiveChart.ChartType = xlXYScatterLines
ActiveChart.Location Whe=xlLocationAsNewSheet
'With ActiveChart
' .HasTitle = False
' .Axes(xlCategory, xlPrimary).HasTitle = False
' .Axes(xlValue, xlPrimary).HasTitle = False
' End With
End Function

Regards,
Srinivas
Andy Pope wrote:
Hi,

You probably need to fully qualify the Cells object, especially if
Charts.add is creating a new chart sheet which does not have cells.

Cheers
Andy

srinivas wrote:
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


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info


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
Help desperately needed with excel charts djewkes Excel Discussion (Misc queries) 10 June 30th 09 02:05 AM
IF Fucntion Help! Chabulo Excel Discussion (Misc queries) 2 April 10th 09 12:50 AM
Help needed for plotting charts/graphs xxbenxx Excel Discussion (Misc queries) 0 January 27th 06 04:44 AM
Help Needed for Charts Mayank Prakash Gupta Excel Discussion (Misc queries) 0 September 21st 05 06:35 AM
daily csv file needed into automatic web charts? dcibrando Excel Programming 1 December 2nd 03 03:12 AM


All times are GMT +1. The time now is 03:48 PM.

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

About Us

"It's about Microsoft Excel"