Hello
I have a code that should run the macro only if the user name is same as defined criteria.. but I don't get the desired result.. even when the user name is matching criteria it gives message box as if the name isn't matching... can someone help please.
I have a code that should run the macro only if the user name is same as defined criteria.. but I don't get the desired result.. even when the user name is matching criteria it gives message box as if the name isn't matching... can someone help please.
VBA Code:
Sub CheckUserName()
If UCase$(Environ("UserName")) <> "requiredname" Then 'And UCase$(Environ("UserName")) <> "GBCAL" Then
MsgBox "User doesn't match requirements. Command terminated."
Else
MsgBox "Macro can be now running.."
End If
End Sub