#1   Report Post  
Posted to microsoft.public.excel.misc
Ribeye
 
Posts: n/a
Default charts.add error

Im trying to add in a chart using a macro and I am running into the Run-time
error '1004': Method 'Add' of object 'Sheets' failed. My code is as follows:
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("C45:G45"),
PlotBy _
:=xlRows
ActiveChart.SeriesCollection(1).XValues = "=Sheet3!R1C2:R1C8"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub

Why is this not working???? Thanks in advance for any help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Debra Dalgleish
 
Posts: n/a
Default charts.add error

Is the workbook protected? That would prevent you from adding a chart sheet.
--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


"Ribeye" wrote:

Im trying to add in a chart using a macro and I am running into the Run-time
error '1004': Method 'Add' of object 'Sheets' failed. My code is as follows:
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("C45:G45"),
PlotBy _
:=xlRows
ActiveChart.SeriesCollection(1).XValues = "=Sheet3!R1C2:R1C8"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub

Why is this not working???? Thanks in advance for any help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
mrice
 
Posts: n/a
Default charts.add error


Which line does the debug happen on?

Martin

http://homepage.ntlworld.com/martin.rice1/


--
mrice
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=532678

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
Ignore error msgs in formula references gharden Excel Discussion (Misc queries) 4 June 17th 05 12:14 AM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM
Problem with VBA returning the contents of a long formula. [email protected] Excel Discussion (Misc queries) 2 February 23rd 05 12:14 AM
ERROR Pinto1uk Excel Discussion (Misc queries) 1 February 8th 05 03:15 AM


All times are GMT +1. The time now is 07:16 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"