Charts.add error

R

Ribeye

Im trying to add a chart using a macro and I keep getting the following
message:
Method 'Add' of object 'sheets' failed error. What is wrong with the code
below?
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("C45:G45"),
PlotBy _
:=xlRows
ActiveChart.SeriesCollection(1).XValues = "=Sheet3!R1C2:R1C8"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub
Thanks in advance for any help......
 
K

K Dales

The error occurs on the very first line. For some reason Excel is in a state
where it cannot add a sheet, but can't tell why from the code you sent since
whatever it is that is preventing it was set before you even get to this
line. The workbook might be protected or you might be in the middle of doing
something else that prevents Excel from being able to add the chart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top