The_Rock
Board Regular
- Joined
- Jul 2, 2007
- Messages
- 174
Hi Folks
I've found online a way to find and replace words in a title for all charts on a sheet but I want to be able to specify specific charts.
In the example below, I only want to update Chart 11.
As I turned off the For/Next statement, I set ch as ChartObject
It crashes on the first line of the IF statement and am out of idea's how else to write the macro.
Please help!
Thanks
I've found online a way to find and replace words in a title for all charts on a sheet but I want to be able to specify specific charts.
In the example below, I only want to update Chart 11.
As I turned off the For/Next statement, I set ch as ChartObject
It crashes on the first line of the IF statement and am out of idea's how else to write the macro.
Please help!
Code:
Sub Change_to_millions()
Dim xWs As Worksheet: Set xWs = Application.ActiveSheet
Dim xFindStr As String
Dim xReplace As String
Dim ch As ChartObject
xFindStr = "000s"
xReplace = "Millions"
ActiveSheet.ChartObjects("Chart 11").Activate
'For Each ch In xWs.ChartObjects
If ch.Chart.HasTitle Then
ch.Chart.ChartTitle.Text = VBA.Replace(ch.Chart.ChartTitle.Text, xFindStr, xReplace, 1)
End If
'Next
Call Millions
End Sub
Thanks