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 compare array of values against value?

Dim res as Variant
res = application.Match(MyVal,My1DArray,0)
if not iserror(res) then
msgbox MyVal & " was fund"
End if

When working with arrays, Match is limited to around 5000 elements in the
array in older versions of excel.

in xl2003, this worked, however:

Sub abcd()
Dim v(1 To 65536) As Long
Dim res As Variant
MyVal = 6
v(65536) = MyVal
res = Application.Match(MyVal, v, 0)
If Not IsError(res) Then
msgbox MyVal & " was found at " & res
End If
End Sub
--
Regards,
Tom Ogilvy


"Rbp9ad" wrote in message
...
How do i check if an items value lies within an array of values? it is a
variable integer array.