Simon Raine
asked on
Excel Scroll bar not initiating change event
I have set up a change event macro if cell a1 is changed, this then runs other macros to set displayed values in a chart.
At present I have linked a drop down list to update value A1. This triggers the change event and runs the macros.
However when I link cell A1 to a scroll bar, the cell value seems to change but the macros do not run.
How can I make the scroll bar change the value in A1 and trigger the change event macro?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("a1")) Is Nothing Then graphselector2
End Sub
Sub graphselector2()
Dim choice
choice = Range("a1")
If choice = 1 Then
Run "aGraph1"
ElseIf choice = 2 Then
Run "aGraph2"
ElseIf choice = 3 Then
Run "aGraph3"
ElseIf choice = 4 Then
Run "aGraph4"
ElseIf choice = 5 Then
Run "aGraph5"
ElseIf choice = 6 Then
Run "aGraph6"
ElseIf choice = 7 Then
Run "aGraph7"
ElseIf choice = 8 Then
Run "aGraph8"
ElseIf choice = 9 Then
Run "aGraph9"
ElseIf choice = 10 Then
Run "aGraph10"
ElseIf choice = 11 Then
Run "aGraph11"
ElseIf choice = 12 Then
Run "aGraph12"
End If
End Sub
Capture.PNG
At present I have linked a drop down list to update value A1. This triggers the change event and runs the macros.
However when I link cell A1 to a scroll bar, the cell value seems to change but the macros do not run.
How can I make the scroll bar change the value in A1 and trigger the change event macro?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("a1")) Is Nothing Then graphselector2
End Sub
Sub graphselector2()
Dim choice
choice = Range("a1")
If choice = 1 Then
Run "aGraph1"
ElseIf choice = 2 Then
Run "aGraph2"
ElseIf choice = 3 Then
Run "aGraph3"
ElseIf choice = 4 Then
Run "aGraph4"
ElseIf choice = 5 Then
Run "aGraph5"
ElseIf choice = 6 Then
Run "aGraph6"
ElseIf choice = 7 Then
Run "aGraph7"
ElseIf choice = 8 Then
Run "aGraph8"
ElseIf choice = 9 Then
Run "aGraph9"
ElseIf choice = 10 Then
Run "aGraph10"
ElseIf choice = 11 Then
Run "aGraph11"
ElseIf choice = 12 Then
Run "aGraph12"
End If
End Sub
Capture.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER