View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Search An Array in VBA

Vlookup supports a two dimensional array

Just a quick demo:

Sub TestVlookup()
Dim v() As Variant
ReDim v(1 To 20, 1 To 5)
For i = 1 To 20
For j = 2 To 4
v(i, j) = Int(Rnd() * 1000 + 1)
Next
v(i, 1) = i
v(i, 5) = Chr(64 + i)
Next
res = Application.VLookup(12, v, 5, False)
MsgBox res
End Sub



--
Regards,
Tom Ogilvy

"Dean Hinson" wrote in message
...
Hello,

I have a multidimensional array that is sorted on the first column and was
trying to use the VLOOKUP to search for particular entries. VLOOKUP

doesn't
seem to reconize arrays. Has anybody been able to incorporate a faster
search other than scanning the array by looping through iterative times?

Any help is appreciated.

Dean.