Changing Secondary Axis Chart Formatting

mtdewrocks

New Member
Joined
Apr 14, 2016
Messages
20
Let me preface this with I am a very new VBA user--with that said, can someone help me figure out how to change my secondary axis formatting? My boss has very particular likes and I am trying to slowly set up a macro that can run and update all formatting to meet his preferences. In this example I changed the primary axis to format as a number with 2 decimal places, and am trying to change the formatting of my secondary axis to change the numbers from something like 140000 to 14 on a chart that is not currently active. I recorded the steps with a macro and then tried to get it to run and I get an error.

Rich (BB code):
Sub selectotherchart()
    Sheets("2-Year Moving Average").Select
    ActiveChart.Axes(xlValue).Select
    Selection.TickLabels.NumberFormat = "#,##0.00"
    ActiveChart.Axes(xlValue, xlSecondary).Select
    ActiveChart.Axes().DisplayUnit = xlThousands----------------->get error saying "Object doesn't support this property or method    ActiveChart.Axes(xlValue, xlSecondary).HasDisplayUnitLabel = False
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try...

Code:
Sub selectotherchart()
    With Sheets("2-Year Moving Average")
        With .ChartObjects("Chart 1").Chart
            .Axes(xlValue).TickLabels.NumberFormat = "#,##0.00"
            .Axes(xlValue, xlSecondary).DisplayUnit = xlThousands
        End With
        .Activate
    End With
End Sub

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,447
Members
452,327
Latest member
kris9926

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top