I'm a beginner - I'm sure someone could fix the code in 10 seconds.
I have graphs - 9 of them - in an excel spreadsheet. I have this VBA code that fixes the scale for these graphs. Only one problem - when I run the Macro, it changes the scale for all 9 graphs. I want to have separate macros for each chart. How can I do this?
Here's my code:
Sub ChangeAxisScales()
Dim objCht As ChartObject
For Each objCht In ActiveSheet.ChartObjects
With objCht.Chart
' Value (Y) Axis
With .Axes(xlValue)
.MaximumScale = ActiveSheet.Range("$AC$3").Value
.MinimumScale = ActiveSheet.Range("$AC$2").Value
.MajorUnit = ActiveSheet.Range("$AC$4").Value
End With
End With
Next objCht
End Sub
I'm pretty sure the problem is the "For Each" argument, but have no idea how to change that to impact the graphs individually.
One graph needs to use max $AB$3, min $AB$2, and Major Unit $AB$4.
Another graph needs $AC$3, $AC$2, and $AC$4, and etc. through column AJ.
Thus, I want one Macro that changes my first graph scale to the AB cells, the second to the AC cells, ... , and the ninth one to AJ cells.
Please help!
Claude
Bookmarks