#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default if with or

hi! I have to use very many if ...end if in my code. to save some space I
want to use if with or (i know this works but i have forgotten the code). Eg

If A(i) = "AAA" Then
A(i) = 1
if A(i) = "Aaa" Then
A(i) = 1
End If
end if

instead i want to have:

If A(i) = "AAA" or "Aaa" Then
A(i) = 1
End If

but i have forgotten how it is written. please help me!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default if with or

Arne,
For the example you have shown:

If (A(i) = "AAA") or (A(i) ="Aaa") Then

The brackets are not required, but I find they clarify what is being
assessed.

But you could also:
If LCase(A(i)) = "aaa" Then
if that is your aim.
Or possibly look at Regular Expressions if the patterns are more
complicated.

NickHK

"Arne Hegefors" wrote in message
...
hi! I have to use very many if ...end if in my code. to save some space I
want to use if with or (i know this works but i have forgotten the code).

Eg

If A(i) = "AAA" Then
A(i) = 1
if A(i) = "Aaa" Then
A(i) = 1
End If
end if

instead i want to have:

If A(i) = "AAA" or "Aaa" Then
A(i) = 1
End If

but i have forgotten how it is written. please help me!




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



All times are GMT +1. The time now is 01:17 PM.

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"