Search an array

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?
 
T

Tim Zych

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.
 
A

art

-----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)"


.
 
A

Alan Beban

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top