rickincanada
Board Regular
- Joined
- Aug 31, 2010
- Messages
- 61
I'm struggling to Set a variable based on an if statement. What I want is to set the variable User = Environ("USERNAME") if the Environ("USERNAME") does not equal userB or userC. If the Environ("USERNAME") does equal userB or userC then I want User = userA. Here's what I have however I'm getting an "Else without If" error. Any help you can provide would be greatly appreciated!
Dim User As String
If Environ("USERNAME") = "userB" Then User = "userA"
If Environ("USERNAME") = "userC" Then User = "userA"
ElseIf Environ("USERNAME") <> "UserB" Or Environ("USERNAME") <> "userC" Then User = Environ("USERNAME")
End If
Dim User As String
If Environ("USERNAME") = "userB" Then User = "userA"
If Environ("USERNAME") = "userC" Then User = "userA"
ElseIf Environ("USERNAME") <> "UserB" Or Environ("USERNAME") <> "userC" Then User = Environ("USERNAME")
End If