Reputation: 867
I have a form control combobox (named DropDown1) on a worksheet. I'm trying to assign an if statement but have been unable to do so.
Sub DropDown1_Change()
If DropDown1.Value = "test" Then
Print (1)
Else
Print (2)
End If
End Sub
Upvotes: 0
Views: 1097
Reputation: 14764
There is nothing wrong with the IF statement itself. What is wrong is what you are doing after the branching occurs.
In other words, the is no Print command. You can use Debug.Print, or you can use MsgBox.
Here is how the code should read:
Private Sub DropDown1_Change()
If DropDown1.Value = "test" Then
Debug.Print 1
Else
Debug.Print 2
End If
End Sub
Upvotes: 1