hmltnangel
Active Member
- Joined
- Aug 25, 2010
- Messages
- 290
- Office Version
- 365
- Platform
- Windows
Just being silly, but is this code right, or is there a better way of writing it? I want it to check if userid input in cell I2 meets the conditions, then run a macro if it does/msg box if it doesnt match. I only want it to run if i2 is changed.
VBA Code:
Sub worksheet_change(ByVal target As Range)
Set target = Range("I2")
If target.Value = Environ$("UserName") Then
Call Macro1 'add macroname
ElseIf target.Value = "1234" Then
Call Macro1 'add macroname
ElseIf target.Value = "2345" Then
Call Macro1 'add macroname
ElseIf target.Value = "3456" Then
Call Macro1 'add macroname
ElseIf target.Value = "4567" Then
Call Macro1 'add macroname
ElseIf target.Value <> Environ$("UserName") Then
MsgBox "UserID does not match Windows Login"
End If
End Sub