VBA: Simple Macro Modification, Help needed

nflami

New Member
Joined
Apr 16, 2014
Messages
25
Hello all,

I found this macro below someone preivously posted and it works great, but I would like to change the macro to only make changes to the active sheet rather than the entire workbook and was having trouble making the correct modifications. Could some help modify the code for me? Thanks!


Code:
Sub dotitles()
    For Each sh In Worksheets
        For Each ch In sh.ChartObjects
            If ch.Chart.HasTitle Then
                ch.Chart.ChartTitle.Text = Replace(ch.Chart.ChartTitle.Text, "Jan", "Feb", 1)
            End If
        Next
    Next
        
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Code:
Sub dotitles()
    For Each ch In ActiveSheet.ChartObjects
        If ch.Chart.HasTitle Then
            ch.Chart.ChartTitle.Text = Replace(ch.Chart.ChartTitle.Text, "Jan", "Feb", 1)
        End If
    Next
End Sub
 
Upvote 0
Code:
Sub dotitles()
For Each ch In ActiveSheet.ChartObjects
    If ch.Chart.HasTitle Then
        ch.Chart.ChartTitle.Text = Replace(ch.Chart.ChartTitle.Text, "Jan", "Feb", 1)
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,020
Messages
6,122,709
Members
449,093
Latest member
Mnur

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