Thread: if with or
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
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!