Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 172
Default Charts.Add error '1004' Method 'Add' of object 'Sheets' failed

The below code was placing a chart on the activesheet by calling data from
that sheet.
But all of a sudden i now get an error.
The only thing i have changed in the workbook was a code for protecting and
unprotecting the workbook.
I have removed these codes to try to get this chart code to work, but i
cannot get rid of this error now.

Can anyone see if i have accidently altered thsi code below, or is there a
error in it ?

The line error highlighted in the CHARTS.ADD

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Private Sub CommandButton21_Click()
Application.ScreenUpdating = False
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData Source:=Sheets("Utilization
Sheet").Range("T41:T42" _
), PlotBy:=xlColumns
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Values = "='Utilization Sheet'!R41C25"
ActiveChart.SeriesCollection(2).Name = "='Utilization Sheet'!R2C25"
ActiveChart.SeriesCollection(1).Values = "='Utilization Sheet'!R41C24"
ActiveChart.SeriesCollection(1).Name = "='Utilization Sheet'!R2C24"
ActiveChart.SeriesCollection(3).Values = "='Utilization Sheet'!R41C26"
ActiveChart.SeriesCollection(3).Name = "='Utilization Sheet'!R2C26"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Utilization
Sheet"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.HasDataTable = False
ActiveChart.PlotArea.Select
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Select
Selection.BarShape = xlCylinder
ActiveChart.SeriesCollection(2).Select
Selection.BarShape = xlCylinder
ActiveChart.SeriesCollection(3).Select
Selection.BarShape = xlCylinder
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.PlotArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "ALL Employee's"
.Elevation = 15
.Perspective = 30
.Rotation = 40
.RightAngleAxes = False
.HeightPercent = 100
.AutoScaling = True
.ChartArea.Select
End With
Range("a1").Select
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

Regards

Corey....

  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default Charts.Add error '1004' Method 'Add' of object 'Sheets' failed

Please stick to the existing thread in the .programming group.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Corey" wrote in message
...
The below code was placing a chart on the activesheet by calling data from
that sheet.
But all of a sudden i now get an error.
The only thing i have changed in the workbook was a code for protecting and
unprotecting the workbook.
I have removed these codes to try to get this chart code to work, but i
cannot get rid of this error now.

Can anyone see if i have accidently altered thsi code below, or is there a
error in it ?

The line error highlighted in the CHARTS.ADD

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Private Sub CommandButton21_Click()
Application.ScreenUpdating = False
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData Source:=Sheets("Utilization
Sheet").Range("T41:T42" _
), PlotBy:=xlColumns
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(2).Values = "='Utilization Sheet'!R41C25"
ActiveChart.SeriesCollection(2).Name = "='Utilization Sheet'!R2C25"
ActiveChart.SeriesCollection(1).Values = "='Utilization Sheet'!R41C24"
ActiveChart.SeriesCollection(1).Name = "='Utilization Sheet'!R2C24"
ActiveChart.SeriesCollection(3).Values = "='Utilization Sheet'!R41C26"
ActiveChart.SeriesCollection(3).Name = "='Utilization Sheet'!R2C26"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Utilization
Sheet"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.HasDataTable = False
ActiveChart.PlotArea.Select
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Select
Selection.BarShape = xlCylinder
ActiveChart.SeriesCollection(2).Select
Selection.BarShape = xlCylinder
ActiveChart.SeriesCollection(3).Select
Selection.BarShape = xlCylinder
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveChart.SeriesCollection(1).Select
ActiveChart.PlotArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "ALL Employee's"
.Elevation = 15
.Perspective = 30
.Rotation = 40
.RightAngleAxes = False
.HeightPercent = 100
.AutoScaling = True
.ChartArea.Select
End With
Range("a1").Select
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~

Regards

Corey....


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 - 'Add' of object 'CommandBarControls' failed LAF Excel Discussion (Misc queries) 1 September 20th 05 01:53 AM
Method 'Add' of object 'CommandBarControls' failed LAF Excel Discussion (Misc queries) 0 September 12th 05 02:02 PM
Object doesn't support this property or method (Error 438) Kiran Excel Discussion (Misc queries) 1 July 12th 05 08:42 PM
Help: runtime error - Method seriescollection object_chart failed huangx06 Charts and Charting in Excel 3 July 9th 05 12:27 AM
Method 'Paste' of object '_Worksheet' failed markline Excel Discussion (Misc queries) 7 May 28th 05 05:02 AM


All times are GMT +1. The time now is 01:28 AM.

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"