multiple if's

  • Thread starter Thread starter snax500
  • Start date Start date
S

snax500

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
 
one way is to use a select case

Code:
Select Case old 
Case "102","103","103"
 
' ------------ do stuff ------------
 
 
'----------------------------
 
Case Else
End Select
 
Last edited:
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top