Unable to get the ChartObjects property ...

strorg

Board Regular
Joined
Mar 27, 2002
Messages
112
I am attempting to use the cobbled code below to determine the current axis of a chart series, and then set a cell value to true of false based on that information. When I execute the code I get a runtime error |Unable to get the ChartObjects property of the worksheet class. Can someone point out the error of my ways?

Regards...Strorg


ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
CurrentAxis = ActiveChart.SeriesCollection(1).AxisGroup

Application.Goto Reference:="ap1a"
If CurrentAxis = 1 Then
ActiveCell.Value = True
Else: ActiveCell.Value = False
End If
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi,

This is probably because the chart isn't called Chart1. The way to check this is to use this code:-

Sub GetChartNames()
Dim chtObject As ChartObject
For Each chtObject In ActiveSheet.ChartObjects
MsgBox chtObject.Name
Next
End Sub

Then change your code to the correct ChartObject name. An alternative is to use this instead:-

ActiveSheet.ChartObjects(1).Activate

This may not work if you have more than one chart on the active sheet.

HTH,
Dan
 
Upvote 0
Thanks for the tip. My error was too obvious...I wasn't selecting the sheet. DUH. Thanks for the troubleshooting tip with the message box. I'll use it in the future.

Regards...Tom
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,064
Members
448,545
Latest member
kj9

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top