Chart Objects vs Chart Number

MrLookout9

New Member
Joined
Jun 25, 2011
Messages
27
Hello and thank you for your expertise.

I am trying to activate Chart 39 on sheet1.


Sheets("Sheet1").ChartObjects(39).Activate

When I run my macro, this line errors out and I get an Application or Object defined error.

I don't believe the problem is with the Sheet. If I change the ChartObjects(1), The correct sheet is chose, but the wrong chart is activated (Chart 44 for some reason).

Are ChartObjects numbered the same as the Chart #?

Any thoughts?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Chart 39 is unlikely to be the 39th chart on the sheet.

Using ChartObjects with a number you are trying to refer to a chart object via it's index in the ChartObjects collection.

Have you tried using the name, 'Chart 39'?
Code:
Sheets("Sheet1").ChartObjects("Chart 39").Activate
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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