Can a zoom in/out chart be made?

R

Ram Nemesis

How can I make a chart which can be zoomed in or out using the mouse or a
button
 
J

John Mansfield

Ram,

One method would be to use macros. You would add a user form with a
scrollbar to your spreadsheet. The scrollbar would zoom the sheet and in
turn zoom the chart.

To do so, create a new code module and call it “Module1â€. Add this code to
the module:

Sub ShowForm()
UserForm1.Show
End Sub

Go to the sheet where your chart resides. Add a button to that sheet via
the Forms toolbar that will activate the scroll form described below. Attach
the macro above to that button.

Next, create a new user form and name it “UserForm1â€. Open the new user
form in design mode. Add a scrollbar to the user form via the VBA controls
toolbar and name it SBZoom. Add this code to the code module in the user
form:

Private Sub UserForm_Initialize()
With SBZoom
.Min = 10
.Max = 400
.SmallChange = 1
.LargeChange = 10
.Value = ActiveWindow.Zoom
End With
End Sub

Private Sub SBZoom_Change()
With ActiveWindow
.Zoom = ScrollBarZoom.Value
.ScrollColumn = ScrollBarColumns.Value
.ScrollRow = ScrollBarRows.Value
End With
End Sub

As you move the scroll bar, the change event will change the size of the
sheet which will in turn size the chart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top