By any chance, is there a way to break chart axes in Excel perhaps through VBA?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
578
Office Version
  1. 365
Platform
  1. Windows
Hello,

I was wondering if there is any way to break chart axes in Excel so that they would look something like Prism graphs? I thought a few years ago I saw some VBA-based solution for this, but I was just searching and didn't see anything. In particular, I use a lot of X,Y scatter charts, and the X axes (for days) are typically like this: 0, 1, 7, 15, 75, 300, and I'm wondering if there is any way I could put a break between 75 and 300? If it is possible, I can share a sample chart if needed.

Thanks for any input!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I came up with an idea to make this possible, but I would need some VBA experts here to help me:

I have attached three pictures to display my idea. You can see that in picture 1, I have a regular xy scatter, and it shows 45 and 60 for the last two points of x axis whereas ideally I would want that 60 to be say 120 to have a large gap between 45 and 120. In my actual charts, the x axis values are generated by formulas, so my first question is whether it is possible for a 'formula' cell to hold a value, i.e. 120, but to show a different value, i.e. 60? 😅 (So the 120 comes from a formula, and the 60 could be specified by the user in a different cell.)

You can see in picture 2 that I manually put a text box with same exact font/color as the actual chart and a solid white background that covers up the numbers at that part of x axis and shows 120. I believe it should be trivial to write a VBA code to show the real axis point, i.e. 120, in this text box based on the actual value in cell H3 and make the box appear/disappear based on whether the number 60 is entered by the user in the different cell as described above?

And you can see that I put a white rectangle to show the break in the graph. I believe it should also be trivial to make this rectangle appear/disappear based on whether the user-specified number, i.e. 60 is entered by the user?

And in the third picture, you can see the final chart with broken x axis and lines :ROFLMAO:

So do you guys think this can be done? It seems to me to be relatively easy. Thanks for any input!


1.png


2.png



3.png
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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