How to zoom on charts using VBA

Rasm

Well-known Member
Joined
Feb 9, 2011
Messages
505
Just wondering if Excel has a zoom function where I can simply highlight a area on a chart - by click and drag kinda deal - then that area is zoomed in on.

I want to do this using VBA
 
GREAT ! But I was specifically interested in the zooming feature and not enlarging of the graph. Though this tool is also very convenient !
 
Last edited by a moderator:
Upvote 0

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
Only 13 years too late!
Set sr = Activesheet.ChartObjects.ShapeRange
sr("Chart 3").height=100
sr(sr.count).height=400 'sets height of last chart on sheet
Regards
Brian
 
Upvote 0
I found the Excel-zoom tool by Weibull (VBA) and it's great and exactly what I need.
Now I have the problem, that it doesn't work on Pivot-Charts. Any idea how to get it working?

Thank you very much,
best regards
 
Upvote 0
To specify: The following error ocurrs:
"The method 'MinimumScale' for the object 'Axis' did not work"
 
Upvote 0
Has anyone ported this code into 2020 ? I tried using it but the rectangular zoom just sticks as a box on the graph without zooming.
 
Upvote 0
Fixed an issue with the 2007 and up version that caused an error if used on dual Y axis charts.

ChartZoom_addin_2007andUP.xlam - 2007 and up
ChartZoom_addin_2000and2003.xla - 2000 & 2003
Weibull, Thank you so much for your code.

I am using Excel 2019, your code works almost fine to me except one problem.

Do
DoEvents
Loop Until ActiveChart.Shapes.Count = shapeCount + 1

It throws error here when I am creating the rectangle. It happens so soon as I click to drag a rectangle.

There are two steps to make a rectangle: click and drag. The problem happens right after the first step. It seems that there are problems with ActiveChart.Shapes.Count since the rectangle is only half created.

Any hint?
 
Upvote 0

Forum statistics

Threads
1,215,247
Messages
6,123,857
Members
449,129
Latest member
krishnamadison

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