View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default multiple conditions for if then else

see if something like this would work:

Sub test()
Dim ws As Worksheet
Select Case UCase(Application.UserName)
Case "USER1", "USER2"
Application.EnableEvents = False
For Each ws In Worksheets(Array("Daily", "Team", "Individual"))
ws.PrintPreview
Next ws
Application.EnableEvents = True
Case Else
End Select
End Sub

--


Gary

"joemeshuggah" wrote in message
...
using the following code to avoid printing restrictions on a specific set of
user ids...what is the correct way to add additional user ids (e.g. User2,
User3, etc) to the if statement?

Private Sub Workbook_BeforePrint(Cancel As Boolean)


If Application.UserName < "User1" Then

Dim ws As Worksheet
Cancel = True
Application.EnableEvents = False
For Each ws In ActiveWindow.SelectedSheets
Select Case ws.Name
Case "Daily", "Team", "Individual": ws.PrintOut
End Select
Next ws
Application.EnableEvents = True

Else

End If

End Sub