Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Bob
 
Posts: n/a
Default Multiple Application.UserNames

I am trying to have an if statement with mulitiple user names.
The current code:
If Application.UserName < "User1" Then
executes properly, but it only works for one user

I want to do something like this:
If Application.UserName < ("User1" Or "User2" Or "User3") Then
This of course is incorrect and shows an error
  #2   Report Post  
Posted to microsoft.public.excel.misc
Norman Jones
 
Posts: n/a
Default Multiple Application.UserNames

Hi Bob,

One way:

If Application.UserName < "User1" _
And Application.UserName < "User2" _
And Application.UserName < "User3" Then

---
Regards,
Norman


"Bob" wrote in message
...
I am trying to have an if statement with mulitiple user names.
The current code:
If Application.UserName < "User1" Then
executes properly, but it only works for one user

I want to do something like this:
If Application.UserName < ("User1" Or "User2" Or "User3") Then
This of course is incorrect and shows an error



  #3   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Multiple Application.UserNames

If Application.UserName < "User1" And _
Application.UserName < "User2" And _
Application.UserName < "User3" Then


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Bob" wrote in message
...
I am trying to have an if statement with mulitiple user names.
The current code:
If Application.UserName < "User1" Then
executes properly, but it only works for one user

I want to do something like this:
If Application.UserName < ("User1" Or "User2" Or "User3") Then
This of course is incorrect and shows an error



  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Multiple Application.UserNames

if application.username = "User1" _
or application.username = "User2" _
or application.username = "User3" then
'it was one of these names
else
'it wasn't one of these names
end if


======
When you get lots of names to check, you may find Select Case easier to read:

Select Case Application.UserName
Case Is = "User1", "User2", "User3"
'do something for these names
Case Is = "User4", "User5", "User6"
'do something for these different names
Case Else
'do something for everyone else
End Select

Bob wrote:

I am trying to have an if statement with mulitiple user names.
The current code:
If Application.UserName < "User1" Then
executes properly, but it only works for one user

I want to do something like this:
If Application.UserName < ("User1" Or "User2" Or "User3") Then
This of course is incorrect and shows an error


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
Bob
 
Posts: n/a
Default Multiple Application.UserNames

Thank you all. Very helpful.

"Dave Peterson" wrote:

if application.username = "User1" _
or application.username = "User2" _
or application.username = "User3" then
'it was one of these names
else
'it wasn't one of these names
end if


======
When you get lots of names to check, you may find Select Case easier to read:

Select Case Application.UserName
Case Is = "User1", "User2", "User3"
'do something for these names
Case Is = "User4", "User5", "User6"
'do something for these different names
Case Else
'do something for everyone else
End Select

Bob wrote:

I am trying to have an if statement with mulitiple user names.
The current code:
If Application.UserName < "User1" Then
executes properly, but it only works for one user

I want to do something like this:
If Application.UserName < ("User1" Or "User2" Or "User3") Then
This of course is incorrect and shows an error


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
External Links and Multiple Instances JMD Excel Discussion (Misc queries) 3 January 3rd 06 09:21 PM
AHHHH-Get Data from Multiple Excel workbooks JAA149 Excel Discussion (Misc queries) 5 October 30th 05 05:19 PM
How do i auto create multiple files from 1 with multiple sheets Kathy Excel Worksheet Functions 0 July 26th 05 01:23 AM
Can I get the mode, min, and max with multiple criteria? BobT Excel Discussion (Misc queries) 1 February 15th 05 03:20 AM
XML / parent with multiple children and with multiple children Richard Excel Discussion (Misc queries) 0 January 5th 05 11:49 AM


All times are GMT +1. The time now is 08:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"