Macro to Change Y Axis Scale for All Selected Charts

HoboEconomist

New Member
Joined
May 6, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to create a macro where a user can select multiple charts on a worksheet, and then upon running the macro, enter the desired Min, Max, and Major Unit values for the Y-Axes for the selected charts. All charts would have the same Y-Axes.

I found the following code snippet to loop through all selected charts, but am struggling with the userform / input macro which the code snippet would call. Could someone please point me in the right direction?

VBA Code:
Dim obj As Object

'Check if any charts have been selected
If Not ActiveChart Is Nothing Then

    Call AnotherMacro(ActiveChart)

Else
    For Each obj In Selection

    'If more than one chart selected
    If TypeName(obj) = "ChartObject" Then

        Call AnotherMacro(obj.Chart)

    End If
Next

End If
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Google Input Box. I think it will get you where you need.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

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