frabulator
Active Member
- Joined
- Jun 27, 2014
- Messages
- 256
- Office Version
- 2019
- Platform
- Windows
I have been trying use a userform to adjust the minimum and maximum value scale on a chart. The problem is that my code keeps saying that "Method 'MinimumScale' of object 'Axis' not found" when trying to resize.
How I am accessing the graph is by first having the user click on the graph (with the macro below):
The above code works great. Then I adjust the scroll bar as needed and run the code below:
The line that is acting up is 'ActiveChart.Axes(xlValue).MinimumScale = mx'. I know i have the chart selected because 'ActiveSheet.ChartObjects(AcSh).Activate' is firing and AcSh is collecting the name of the chart in question.
Any help on this would be greatly appreciated. I'm sure it is something silly that I am over looking but I have been stuck on this for days.
~Frab
How I am accessing the graph is by first having the user click on the graph (with the macro below):
Code:
Sub OpenZoomPan(control As IRibbonControl)
Dim selectionType As String
If TypeName(Selection) = "ChartArea" Or TypeName(Selection) = "PlotArea" Then
Set chart_from_selection = Selection.Parent
UserForm9.Show
ElseIf TypeName(Selection) = "Series" Then
Set chart_from_selection = Selection.Parent.Parent
UserForm9.Show
Else
MsgBox ("Please select a chart to continue.")
End If
End Sub
The above code works great. Then I adjust the scroll bar as needed and run the code below:
Code:
Sub ZoomAndPann()
application.ScreenUpdating = False
'X
Dim mx As Double
mx = UserForm9.Original_X_min - (UserForm9.Original_X_min * (UserForm9.ScrollBar3.Value / (UserForm9.ScrollBar3.Max / 2)))
Dim xx As Double
xx = UserForm9.Original_X_max - (UserForm9.Original_X_max * (UserForm9.ScrollBar3.Value / (UserForm9.ScrollBar3.Max / 2)))
Dim AcSh As String
AcSh = chart_from_selection.Name
AcSh = Mid(AcSh, Len(ActiveSheet.Name) + 2, Len(AcSh) - (Len(ActiveSheet.Name) + 1))
ActiveSheet.ChartObjects(AcSh).Activate
'X
ActiveChart.Axes(xlValue).MinimumScale = mx
ActiveChart.Axes(xlValue).MaximumScale = xx
'Y
ActiveChart.Axes(xlCategory).MinimumScale = mx
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MaximumScale = xx
application.ScreenUpdating = True
End Sub
The line that is acting up is 'ActiveChart.Axes(xlValue).MinimumScale = mx'. I know i have the chart selected because 'ActiveSheet.ChartObjects(AcSh).Activate' is firing and AcSh is collecting the name of the chart in question.
Any help on this would be greatly appreciated. I'm sure it is something silly that I am over looking but I have been stuck on this for days.
~Frab