Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this. Make sure the ScrollBar is linked to a cell, in my example it is <code>J5</code> but modify that as needed.</p> <p>This macro will compare the current axis <code>.MinimumScale</code> to the value of the linked cell, and will zoom in and out.</p> <p><img src="https://i.stack.imgur.com/3oWH0.jpg" alt="Format control to a linked cell"></p> <p>Also make sure that the min/max and incremental values for the ScrollBar are set accordingly, for example:</p> <p><img src="https://i.stack.imgur.com/NwY8z.jpg" alt="Set the scroll bar properties"></p> <pre><code>Sub ScrollBar1_Change() Dim ax As Axis Dim sbMin As Double Dim sbMax As Double Dim sbMove As Double Dim sbVal As Double Dim minVal As Double Dim maxVal As Double sbMin = 0 '## Set this to the minimum desired axis scale.' sbMax = 0.6 '## set this to the maximum desired axis scale.' sbMove = 0.1 '## Set this to the desired increment.' sbVal = Range("J5").Value '## this is the cell linked to the scrollbar, modify as needed.' Set ax = ActiveSheet.ChartObjects("Chart 20").Chart.Axes(xlCategory) With ax '## check to see if we are zooming out, and flip the sign on sbMove' If sbVal &lt; .MinimumScale Then sbMove = sbMove * -1 '## Manipulate the axis min &amp; max:' If Not sbVal &gt;= 0.5 * sbMax Then '## Manipulate the axis min &amp; max:' If (.MinimumScale &lt;&gt; sbVal) Then .MinimumScale = .MinimumScale + sbMove .MaximumScale = .MaximumScale - sbMove .CrossesAt = sbVal End If End If End With End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload