View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
tony h[_43_] tony h[_43_] is offline
external usenet poster
 
Posts: 1
Default VBA equivalent for SQL 'IN' function


I am not sure of a direct equivalent but three options:
1. You could use a delimited list and then

if instr(1, "!A!B!C!" , "!" & myvar & "!") < 0 then etc

2. use

Select Case myvar
Case "A", "B", "C"
'do my stuff
End Select


3 create your own function to do it such as

Function myIN(strSearch, ParamArray strIN()) As Boolean
Dim v As Variant

myIN = False

For Each v In strIN()
If strSearch = v Then
myIN = True
Exit For
End If
Next
End Function

if myin(myvar,"B","C","A") then

Regard

--
tony
-----------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=50748