Activeworkbook.Charts.count=0

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,066
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I tried to loop through all the charts in a workbook without success.

On troubleshooting, I realized that Activeworkbook.Charts.count=0 even when there are charts in the workbook. Am certain am pointing to the right workbook too
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,079
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Are they chart sheets, or embedded charts? Charts.Count only refers to chart sheets.
 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,066
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Are they chart sheets, or embedded charts? Charts.Count only refers to chart sheets.

They are not chart sheets, they are just chart objects on different worksheets

When I loop through the worksheets and thru the chart objects on each sheet, it seems to work but am wondering why I can't simply get a count of the "chartobjects" or charts in a workbook with that line
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,079
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Because that's not what it does.
 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,066
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

Because that's not what it does.
Thanks Rory

So how would you have gone about it?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,079
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Loop the sheets and use the chartobjects.count for each one.
 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,066
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

Loop the sheets and use the chartobjects.count for each one.
Thanks. I did that already. Thought there was some way to avoid the Nested loops, doesn't appear so :)
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,079
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
There shouldn't be a nested loop - you only need to loop the worksheets to count the chartobjects.
 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,066
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
There shouldn't be a nested loop - you only need to loop the worksheets to count the chartobjects.
I didn't post the complete scope of what I intend to do. I actually want to perform some actions on each chart, hence my last post. Say I want to edit all chart titles, I would have to loop through each worksheet and loop through the chartobjects on that sheet, that's what I meant, so its a nested loop case
 

Jon Peltier

MrExcel MVP
Joined
May 14, 2003
Messages
4,943
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
If the chart objects are on separate worksheets, you need to loop, that's just the hierarchy of the Excel object model. It's not a big deal.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,719
Messages
5,597,736
Members
414,170
Latest member
Mdm

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
Top