How to find all charts on a sheet

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
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,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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