How to find all charts on a sheet

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
This assumes that the charts are embedded in a worksheet and lists their names and worksheet name in column A.

Sub FindCharts()
Dim cht As ChartObject
Dim sht As Worksheet

For Each sht In ThisWorkbook.Worksheets
For Each cht In sht.ChartObjects
Sheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0).Value = cht.Name & " is on " & sht.Name
Next cht
Next sht
End Sub


HTH

Regards
 
Upvote 0
Thanks got that to work

I am trying to set the name of each line. When I recorded a macro it looked like

ActiveChart.SeriesCollection(1).Name = "=""Gas"""

in Vb I use

ActiveChart.SeriesCollection(NumL).Name = "=" & nameProp & ""
where numL = 1 and nameProp = Gas (read from a cell)

Error is "Unable to set name property of Series class" (The chart is already on a sheet)
 
Upvote 0
Try this

ActiveChart.SeriesCollection(NumL).Name = nameProp

You've assigned the name to the variable so no need for the extra "".

Regards
 
Upvote 0
Thanks, I am able to write VB code, but am not to skilled using ideas like

Dim cht As ChartObject
Dim sht As Worksheet

So in general, my code is not as "elegant" and probably not as simple
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,809
Members
449,048
Latest member
greyangel23

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