Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
if statement with or
if cUser = "XJOHN" _
or cUser = "YPAUL" then or you could use a select case structu select case cUser case is = "XJOHN", "XPAUL" 'DO THE WORK Sometimes, that "select case" structure is lots easier to modify when you want to add more options. 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
if statement with or
Try this! Hope this helps! If so, let me know, click "YES" below
Sub UnprotectAllSheets() Dim cUser As String Dim wSheet As Worksheet 'change to uppercase because this seems to be case sensitive. cUser = UCase(Environ("username")) If cUser = "XJOHN" Or cUser = "YPAUL" Then Dim wSheet As Worksheet For Each wSheet In ActiveWorkbook.Worksheets wSheet.Unprotect Password:="opensesame" Next Else UserForm1.Show End If End Sub -- Cheers, Ryan "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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF statement inside a SUMIF statement.... or alternative method | Excel Worksheet Functions | |||
Reconcile Bank statement & Credit card statement & accounting data | Excel Worksheet Functions | |||
Embedding an OR statement in an IF statement efficiently | Excel Discussion (Misc queries) | |||
appending and IF statement to an existing IF statement | Excel Worksheet Functions | |||
If statement and Isblank statement | Excel Worksheet Functions |