bopha99
10-30-2014, 04:17 PM
Hello,
I am running:
Sub ScaleAxes()
With ActiveChart.Axes(xlCategory, xlPrimary)
.MaximumScale = ActiveSheet.Range("h10").Value
.MinimumScale = ActiveSheet.Range("h11").Value
.MajorUnit = ActiveSheet.Range("h12").Value
End With
With ActiveChart.Axes(xlValue, xlPrimary)
.MaximumScale = ActiveSheet.Range("i10").Value
.MinimumScale = ActiveSheet.Range("i11").Value
.MajorUnit = ActiveSheet.Range("i12").Value
End With
End Sub
to scale my axes in a chart. My axes are here:
Axis
X
Y
Max
10
900000
Min
0
500000
Tick
1
100000
where h10 is 10 and i10 is 900000. The axes shown above is on tab "Calculations." The chart that I want is on tab "Fee Analysis". I am getting the error Run-time error '-2147467259 (80004005)': Method 'MaximumScale' of object 'Axis' failed....What am I doing wrong? What can I do to get this to work?
Also, if you know how to add into the vba code so that in the chart the last value on both lines comes up as a data label in dollars with nothing after the decimal point that would be awesome. Thanks in advance.
I am running:
Sub ScaleAxes()
With ActiveChart.Axes(xlCategory, xlPrimary)
.MaximumScale = ActiveSheet.Range("h10").Value
.MinimumScale = ActiveSheet.Range("h11").Value
.MajorUnit = ActiveSheet.Range("h12").Value
End With
With ActiveChart.Axes(xlValue, xlPrimary)
.MaximumScale = ActiveSheet.Range("i10").Value
.MinimumScale = ActiveSheet.Range("i11").Value
.MajorUnit = ActiveSheet.Range("i12").Value
End With
End Sub
to scale my axes in a chart. My axes are here:
Axis
X
Y
Max
10
900000
Min
0
500000
Tick
1
100000
where h10 is 10 and i10 is 900000. The axes shown above is on tab "Calculations." The chart that I want is on tab "Fee Analysis". I am getting the error Run-time error '-2147467259 (80004005)': Method 'MaximumScale' of object 'Axis' failed....What am I doing wrong? What can I do to get this to work?
Also, if you know how to add into the vba code so that in the chart the last value on both lines comes up as a data label in dollars with nothing after the decimal point that would be awesome. Thanks in advance.