How to find all charts on a sheet

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,911
Messages
6,122,199
Members
449,072
Latest member
DW Draft

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