How to make Zero's line up on Chart with 2 Y Axes

Grothgar

Board Regular
Joined
Jul 25, 2011
Messages
62
Hi All;

I have been thinking about this problem for a long time, but am no closer to coming up with a solution.

I have a report where, by changing one drop-down menu, it updates a vast variety of charts, most of which have data which uses two sets of Y Axes.

However, if I change the scales on either axis to make X axis cross at the Zero point on both sides, this only works for that particular option, as soon as I change the option, the chart is worthless.

So, what I am asking for you help in, is for some VBA code which will automatically change the max, min and major unit of the charts, so that everything is much clearer as to how the two sets of data relate (which is hard when the X Axis crosses on Y axis at 0, and the other at -30!)

If you need anymore information, please let me know.

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Thanks for that... it works... although I really don't understand how :)

I have noticed that this only works on the Active Chart... if I have 8 charts, how would I make this work on all of them at once... or one after the other?
 
Upvote 0
You could run something like this:

Code:
Sub AlignAllChartYAxes()
  Dim cho As ChartObject
  For Each cho in ActiveSheet.ChartObjects
    cho.Activate
    AlignY 1 ' pick value from 1 to 4 that fits all charts best
  Next cho
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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