Search an array

  • Thread starter Thread starter arts
  • Start date Start date
A

arts

Assume an array of string type, and a string varible. Is
there a function or shortcut way of identifying the index
number of the first element whose value matches the value
of the variable?
 
One way is Excel's Match function:

Application.Match(lookup_val, arr(), 0)

returns either the index position of the value found in the list, or an
error if not found, so use a variant and trap the error using IsError.
 
-----Original Message-----
One way is Excel's Match function:

Application.Match(lookup_val, arr(), 0)

returns either the index position of the value found in the list, or an
error if not found, so use a variant and trap the error using IsError.


"(e-mail address removed)"


.
 
Application.Match is 1-based, so you will need to adjust for 0-based
arrays (or, for that matter, for an n-based array where n is not 1).

Alan Beban
 
Back
Top