Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the Select Case statement as an alternative to using ElseIf in
If...Then...Else statements when comparing one expression to several different values. While If...Then...Else statements can evaluate a different expression for each ElseIf statement, the Select Case statement evaluates an expression only once, at the top of the control structure. Example1: If Application.UserName = "User1" Then your code Else if Application.UserName = "User2" then End if Example2: Select Case UserID Case User1 Your code Case User2,User3 Your code Case User4 Your code Case Else Your Code End Select -- If this posting was helpful, please click on the Yes button. Regards, Michael Arch. "joemeshuggah" wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
count for multiple conditions in multiple columns | Excel Worksheet Functions | |||
Setting multiple conditions to return a figure from multiple cells | Excel Discussion (Misc queries) | |||
SUMPRODUCT or INDEX/MATCH for multiple conditions and multiple rec | Excel Discussion (Misc queries) | |||
Combining Text from multiple cells under multiple conditions | Excel Worksheet Functions | |||
How to multiple conditions to validate more than 2 conditions to . | Excel Worksheet Functions |