ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List Charts Macro (https://www.excelbanter.com/excel-programming/300616-list-charts-macro.html)

Phil Hageman[_3_]

List Charts Macro
 
This sub creates a message box listing worksheet charts, by chart number. Can the code be modified to show the chart title after the chart name

Sub ListCharts(
Dim Msg As Strin
Dim ChtObj As ChartObjec
Msg = "Worksheet: " & ActiveSheet.Name & vbCrL
For Each ChtObj In ActiveSheet.ChartObject
Msg = Msg & vbCrLf & ChtObj.Nam
Nex
MsgBox Ms
End Sub

Andy Pope

List Charts Macro
 
Hi Phil,

Try this,

Sub ListCharts()
Dim Msg As String
Dim ChtObj As ChartObject
Msg = "Worksheet: " & ActiveSheet.Name & vbCrLf
For Each ChtObj In ActiveSheet.ChartObjects
If ChtObj.Chart.HasTitle Then
Msg = Msg & vbCrLf & ChtObj.Name & " " &
ChtObj.Chart.ChartTitle.Text
Else
Msg = Msg & vbCrLf & ChtObj.Name
End If
Next
MsgBox Msg
End Sub

Cheers
Andy

Phil Hageman wrote:

This sub creates a message box listing worksheet charts, by chart number. Can the code be modified to show the chart title after the chart name?

Sub ListCharts()
Dim Msg As String
Dim ChtObj As ChartObject
Msg = "Worksheet: " & ActiveSheet.Name & vbCrLf
For Each ChtObj In ActiveSheet.ChartObjects
Msg = Msg & vbCrLf & ChtObj.Name
Next
MsgBox Msg
End Sub


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

Tom Ogilvy

List Charts Macro
 
http://support.microsoft.com/?id=177760
VBA: How to Run Macros in Other Office Programs


http://support.microsoft.com/?id=210111
ACC2000: Using Microsoft Access as an Automation Server

http://support.microsoft.com/?id=253338
INFO: Office Developer Samples and Tools Available for Download

http://support.microsoft.com/?id=260410
OFF2000: Microsoft Office 2000 Automation Help File Available

--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
This sub creates a message box listing worksheet charts, by chart number.

Can the code be modified to show the chart title after the chart name?

Sub ListCharts()
Dim Msg As String
Dim ChtObj As ChartObject
Msg = "Worksheet: " & ActiveSheet.Name & vbCrLf
For Each ChtObj In ActiveSheet.ChartObjects
Msg = Msg & vbCrLf & ChtObj.Name
Next
MsgBox Msg
End Sub




Andy Pope

List Charts Macro
 
Hi Phil,

Hopefully its just a line wrapping problem.

Msg = Msg & vbCrLf & ChtObj.Name & _
" " & ChtObj.Chart.ChartTitle.Text

Cheers
Andy

Phil Hageman wrote:

Andy, Thanks for your reply. When running the code, I get a Compile error: syntax error on the line:
Msg = Msg & vbCrLf & ChtObj.Name & " " &

Thanks,
Phil


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

Phil Hageman[_3_]

List Charts Macro
 
Thanks, Andy. Works great
Phil


All times are GMT +1. The time now is 09:00 AM.

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