Activate existing chart

VBA_Newbie

Active Member
Joined
Jan 7, 2005
Messages
258
I'm trying to activate an existing chart but I keep getting an error "Subscript out of range". Here is the code I'm using. Any thoughts?

Worksheets("Pricing").ChartObjects("Chart 5").Activate
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
hi mike.

are you sure you have a chart named "Chart 5"? are you sure you have a worksheet named "Pricing"? if yes to both, is chart 5 on pricing?

cheers. ben.
 
Upvote 0
Yes to both. When I right-click on embedded object and go to chart window...it says it is named "Chart 5". I can't figure it out.
 
Upvote 0
hi mike.

try running this code to see what chartobjects are on your sheet (you'll need to change wsSearch to the applicable worksheet)

Code:
Sub FindChartObject()

    Dim wsSearch As Worksheet
    Dim cht As ChartObject
    
    Set wsSearch = Worksheets("Sheet1")
    
    For Each cht In wsSearch.ChartObjects
        cht.Activate
        MsgBox cht.Name
    Next cht
    
End Sub
 
Upvote 0
I'm an idiot...I had accidently put a space at end of the worksheet name "Pricing"....Sorry for the trouble.
 
Upvote 0

Forum statistics

Threads
1,225,761
Messages
6,186,893
Members
453,383
Latest member
SSXP

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