View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.newusers
tinman[_2_] tinman[_2_] is offline
external usenet poster
 
Posts: 3
Default if statement with or

Hello,

Could someone help me understand why it doesn't like "If cUser =
"XJOHN" Or "YPAUL" Then" in the macro below? Thanks.

Sub UnprotectAllSheets()
Dim cUser As String
cUser = UCase(Environ("username")) 'change to uppercase because
this seems to be case sensitive.
If cUser = "XJOHN" Or "YPAUL" Then

Dim wSheet As Worksheet
For Each wSheet In ActiveWorkbook.Worksheets
wSheet.Unprotect Password:="opensesame"
Next

Else
UserForm1.Show
End If
End Sub