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 |
if statement with or
Check your other post.
tinman wrote: 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 -- Dave Peterson |
All times are GMT +1. The time now is 11:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com