Hello, I am trying to have a Worksheet_Change that will run a VBA code. Right now I have the first part done. What this code does is that it works with a Drop-down list in Cell V6 and when someone selects this drop-down list it will run a code called Do_it_1 and also change a commandbutton caption. This works great so far.
What I would like to do is, make this same code work for cell $V$2, which is also a drop-down list. When I tried to have them two separate items I would get a compile error: Ambiguous name detected:worksheet_change.
Here is my code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Address <> "$V$6" Then Exit Sub
Application.Run "Do_it_1"
Select Case CommandButton1.Caption
Case "Hide Object Detail"
CommandButton1.Caption = "Expand Objects"
End Select
End Sub
Is there a way to add my second target address into my code? Also, I have not thought of this yet, will this only effect the active worksheet and not other worksheets in the same workbook? I would rather keep this to the active sheet only. Thank you for your help.
What I would like to do is, make this same code work for cell $V$2, which is also a drop-down list. When I tried to have them two separate items I would get a compile error: Ambiguous name detected:worksheet_change.
Here is my code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Address <> "$V$6" Then Exit Sub
Application.Run "Do_it_1"
Select Case CommandButton1.Caption
Case "Hide Object Detail"
CommandButton1.Caption = "Expand Objects"
End Select
End Sub
Is there a way to add my second target address into my code? Also, I have not thought of this yet, will this only effect the active worksheet and not other worksheets in the same workbook? I would rather keep this to the active sheet only. Thank you for your help.
Last edited by a moderator: