Hi protonLeah. Thanks for the reply.
I followed your advice but when I got to the "select the desired macro" stage I realized there wasn't such thing as a macro for that button. So I went back to the original file which I used as a template and then compared its VBA code with the one in the file I am editing. Guess what? I copied their code that was typed in something called "Module", created a "Module" back in my file's VBA code, pasted the copied code into it, followed your steps and assigned the macro to the button. Now it works beautifully. Not only that: I managed to change the worksheet's name too!
The code was:
Sub set_axis_options()
Dim cht As Chart
'change chart name here
Set cht = Sheets("Gantt Chart").ChartObjects("gantt_chart").Chart
With cht.Axes(xlValue, xlPrimary)
.MaximumScale = Range("ed_date").Value
.MinimumScale = Range("st_date").Value
.MajorUnit = 31
End With
Sheets("Gantt Chart").Select
End Sub
And now it looks like this:
Sub set_axis_options()
Dim cht As Chart
'change chart name here
Set cht = Sheets("Active Projects").ChartObjects("gantt_chart").Chart
With cht.Axes(xlValue, xlPrimary)
.MaximumScale = Range("ed_date").Value
.MinimumScale = Range("st_date").Value
.MajorUnit = 10
End With
Sheets("Active Projects").Select
End Sub
Thanks for the help mate!
Bookmarks