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
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

C Moore

Well-known Member
Joined
Jan 17, 2014
Messages
557
Office Version
  1. 365
Platform
  1. Windows
Google Input Box. I think it will get you where you need.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,205
Messages
5,623,364
Members
415,969
Latest member
Rey99

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
Top