ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping Through Charts / ChartObjects (https://www.excelbanter.com/excel-programming/333100-looping-through-charts-chartobjects.html)

William Benson[_2_]

Looping Through Charts / ChartObjects
 
Hi, I know the last paragraph below has a bad syntax, but what I want to do
is loop through charts on all worksheets and print the formulas of each of
the charts' series. I DO NOT want to activate the chart, can you please
repair my syntax/object references? Thanks!!!!!!!

Dim ch As Chart
Dim chObj As Object
Dim Sh As Worksheet
Dim Ser As Series

'This code works fine for chart sheets
For Each ch In ThisWorkbook.Charts
For Each Ser In ch.SeriesCollection
Debug.Print Ser.Formula
Next Ser
Next ch

'This code FAILS for charts embedded in worksheet (not a chart sheet)
For Each Sh In ThisWorkbook.Worksheets
For Each chObj In Sh.ChartObjects
For Each Ser In chObj.SeriesCollection 'This property donesn't
exist!!
Debug.Print Ser.Formula
Next Ser
Next chObj
Next Sh




Ed Ferrero[_5_]

Looping Through Charts / ChartObjects
 
HI William Benson,

For Each Ser In chObj.Chart.SeriesCollection

Ed Ferrero
http://edferrero.m6.net

Hi, I know the last paragraph below has a bad syntax, but what I want to
do is loop through charts on all worksheets and print the formulas of each
of the charts' series. I DO NOT want to activate the chart, can you please
repair my syntax/object references? Thanks!!!!!!!

Dim ch As Chart
Dim chObj As Object
Dim Sh As Worksheet
Dim Ser As Series

'This code works fine for chart sheets
For Each ch In ThisWorkbook.Charts
For Each Ser In ch.SeriesCollection
Debug.Print Ser.Formula
Next Ser
Next ch

'This code FAILS for charts embedded in worksheet (not a chart sheet)
For Each Sh In ThisWorkbook.Worksheets
For Each chObj In Sh.ChartObjects
For Each Ser In chObj.SeriesCollection 'This property donesn't
exist!!
Debug.Print Ser.Formula
Next Ser
Next chObj
Next Sh






William Benson[_2_]

Looping Through Charts / ChartObjects
 
Perfect, thank you Ed.


"Ed Ferrero" wrote in message
...
HI William Benson,

For Each Ser In chObj.Chart.SeriesCollection

Ed Ferrero
http://edferrero.m6.net

Hi, I know the last paragraph below has a bad syntax, but what I want to
do is loop through charts on all worksheets and print the formulas of
each of the charts' series. I DO NOT want to activate the chart, can you
please repair my syntax/object references? Thanks!!!!!!!

Dim ch As Chart
Dim chObj As Object
Dim Sh As Worksheet
Dim Ser As Series

'This code works fine for chart sheets
For Each ch In ThisWorkbook.Charts
For Each Ser In ch.SeriesCollection
Debug.Print Ser.Formula
Next Ser
Next ch

'This code FAILS for charts embedded in worksheet (not a chart sheet)
For Each Sh In ThisWorkbook.Worksheets
For Each chObj In Sh.ChartObjects
For Each Ser In chObj.SeriesCollection 'This property donesn't
exist!!
Debug.Print Ser.Formula
Next Ser
Next chObj
Next Sh









All times are GMT +1. The time now is 03:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com