View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 1,071
Default Searching an Array

Something like:

Option Explicit

Sub testIt()
Dim x(1 To 10), i As Integer

For i = 1 To 10
x(i) = Chr(64 + i)
Next i
On Error Resume Next
i = Application.WorksheetFunction.Match("harry", x, 0)
MsgBox "harry " & IIf(Err.Number 0, "not ", "") & "found"

Err.Clear
x(UBound(x)) = "harry"
i = Application.WorksheetFunction.Match("harry", x, 0)
MsgBox "harry " & IIf(Err.Number 0, "not ", "") & "found"
On Error GoTo 0

End Sub


--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , ottomocobia97
@bellsouth.net says...
Excel 2002, WinXP
I built an array of people's names, say People().
I want to find out if Harry is in that array.
I don't want to find Harry's position within the array, just if he is in
the array.
How would I code that search?

Thanks for your help. Otto