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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,215,204
Messages
6,123,630
Members
449,109
Latest member
Sebas8956

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