Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.MajorGridlines problem

Status
Not open for further replies.

ETID

Programmer
Jul 6, 2001
1,867
US
Hi Gang, ...any clues on this one?

I want to change the the gridline scale of a chart via VBA...

When I record the steps, excel gives me this code
yet excel will not run it.

error: #1004 (unable to set the minimumscaleisauto property of the axis class)
'----------------------------------------------

sub set_axes
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).MajorGridlines.Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = 100
.MinorUnit = 1
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
end sub
 
Not sure, try setting everything explicitly...

Code:
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    With ActiveChart.Axes(xlValue)
        .MinimumScale = 1
        .MaximumScale = 10
        .MinorUnit = 1
        .MajorUnit = 3
        .Crosses = xlAutomatic
        .ReversePlotOrder = False
        .ScaleType = xlLinear
        .DisplayUnit = xlNone
    End With[\code]
 
Thanks, but still a no go :-(
 
Make sure you actually have gridlines and didn't delete them accidentally? Not sure but I ran the code I gave you myself and it worked fine on a simple chart...

MEP
 
Thanks for your time,...I figured it out.

I have multiple hidden axises (to create a detailed x-axis table)


That was confusing the recorder as to what axis that I had actually selected.


I rebuilt the chart, recorded the major gridlines macro, then added the hidden elements,..it now works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top