• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to automatically adjust charts axis based on cell values

Josedv

New Member
Hi there,


I've got various different charts on a sheet. I am looking for a Macro to automatically adjust the maximum and minimum scale of the axis as well as the point where the horizontal axis crosses. The macro I am working with is (just for two graphs for the sake of this example)


Sub ejesautomaticos()

With ActiveSheet.ChartObjects("BFRTC").Chart

.Axes(xlValue).MinimumScale = Range("'Average'!AM85").Value

.Axes(xlValue).MaximumScale = Range("'Average'!AM86").Value

.Axes(xlValue).CrossesAt = Range("'Average'!AN86").Value

End With

With ActiveSheet.ChartObjects("VLLTC").Chart

.Axes(xlValue).MinimumScale = Range("'Average'!N85").Value

.Axes(xlValue).MaximumScale = Range("'Average'!N86").Value

.Axes(xlValue).CrossesAt = Range("'Average'!085").Value

End With

End Sub


I am getting and error on this line:

.Axes(xlValue).CrossesAt = Range("'Average'!AN86").Value


What should I do get around the error?


Thanks

Josedv
 
Hi Josedv ,


I tried out your macro , and I did not get any error ; can you mention what error you get , and what the cell 'Average'!AN86 contains ?


Also , your second segment contains the following statement :


.Axes(xlValue).CrossesAt = Range("'Average'!085").Value


where the cell address uses 0 ( zero ) instead of an upper case O ( the letter ).


Narayan
 
Back
Top