Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default multiple if's

I have to convert many accounts to a new account string. I have many
Or's. Is there a better way to code this? ( I actually have 16 Or's- I
only show 4 for the example):

For Each cll In Selection
old = Right(cll, 4)
If old = "0101" Or old = "0102" Or old = "0103" Or old = "0104"
Then
CONVERT CLL
End If
Next


Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default multiple if's

Not really a whole lot of information to go on. But, I would most
likely use a Select Case statement
Select Case old
Case "0101"
whatever goes here
Case "0102"
something else goes here
End Select

You can include a Case Else statement at the end of the Case
statements if you need to.
snax500 wrote:
I have to convert many accounts to a new account string. I have many
Or's. Is there a better way to code this? ( I actually have 16 Or's- I
only show 4 for the example):

For Each cll In Selection
old = Right(cll, 4)
If old = "0101" Or old = "0102" Or old = "0103" Or old = "0104"
Then
CONVERT CLL
End If
Next


Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default multiple if's

For Each cll In Selection
Select Case Right(cll, 4)
Case "0101","0102" ,"0103", "0104" 'you might get away with Case "0101" to
"0104" here but needs testing
CONVERT CLL
Case 'another list
Case 'yet another list
Do something
Case Else
Only do something here if none of the others above have triggered
End Select
Next


--
p45cal


"snax500" wrote:

I have to convert many accounts to a new account string. I have many
Or's. Is there a better way to code this? ( I actually have 16 Or's- I
only show 4 for the example):

For Each cll In Selection
old = Right(cll, 4)
If old = "0101" Or old = "0102" Or old = "0103" Or old = "0104"
Then
CONVERT CLL
End If
Next


Thanks


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
Multiple IF's with an OR Nadine Excel Worksheet Functions 5 June 4th 10 05:37 PM
Multiple IF's to Select a Value JerryS Excel Worksheet Functions 6 May 9th 07 12:53 AM
Multiple If's and OR's Shelly Excel Worksheet Functions 16 February 19th 07 11:44 PM
multiple IF's ? foilprint0 Excel Worksheet Functions 1 January 31st 06 04:59 PM
Formula with multiple IF'S Kim46770 Excel Discussion (Misc queries) 2 May 17th 05 10:31 PM


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

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

About Us

"It's about Microsoft Excel"