Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
dan dan is offline
external usenet poster
 
Posts: 866
Default second or third match in vlookup() or Match()

Is it possible to get the second or third match instead of the first?
Thank you
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default second or third match in vlookup() or Match()

Say in A1 thru A100 we have:

now
is
the
time
for
all
good
men
to
sidney
or
some
other
place
other
than
sidney

=MATCH("sidney",A1:A100,0) will find the first sidney


Clearly if the first sidney is in cell A10, then to find the "next" sidney
we would like to use:


=MATCH("sidney",A11:A100,0)+10 but automate the process.


So if D1 contains:


=MATCH("sidney",A1:A100,0)
then in D2 enter:
=MATCH("sidney",INDIRECT("A" & D1+1 & ":A100"),0)+D1
and copy down. This will give you the row numbers of all the "sidneys"



--
Gary''s Student - gsnu200789


"Dan" wrote:

Is it possible to get the second or third match instead of the first?
Thank you

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default second or third match in vlookup() or Match()

Assuming your data starts in Row 2 (with Row 1 being a header row), and that
the text you want to find is in B2 and the instance number of the text you
want to find is in C2, this array-entered** formula will return the ROW
NUMBER of that instance of the text...

=SMALL(IF(A2:A1000<B2,"",(A2:A1000=B2)*ROW(A2:A10 00)),C2)

** Array-entered means commit the formula using Ctrl+Shift+Enter, not just
Enter by itself.

Rick


"Dan" wrote in message
...
Is it possible to get the second or third match instead of the first?
Thank you


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default second or third match in vlookup() or Match()

Try this array formula** :

D1 = lookup value

=INDEX(B1:B10,SMALL(IF(A1:A10=D1,ROW(B1:B10)-MIN(ROW(B1:B10))+1),n))

Where n = the instance number you want to find.

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

--
Biff
Microsoft Excel MVP


"Dan" wrote in message
...
Is it possible to get the second or third match instead of the first?
Thank you



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default second or third match in vlookup() or Match()

Assuming all ranges start in Row 1, doesn't this do what your formula does?

=INDEX(B1:B10,SMALL(IF(A1:A10=D1,ROW(B1:B10)),n))

All I did was remove the beginning row adjustment from you formula, namely
this part...

-MIN(ROW(B1:B10))+1

Or were you assuming your formula would be copied down (I didn't get that as
a requirement from the OP's posting).

Rick


"T. Valko" wrote in message
...
Try this array formula** :

D1 = lookup value

=INDEX(B1:B10,SMALL(IF(A1:A10=D1,ROW(B1:B10)-MIN(ROW(B1:B10))+1),n))

Where n = the instance number you want to find.

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

--
Biff
Microsoft Excel MVP


"Dan" wrote in message
...
Is it possible to get the second or third match instead of the first?
Thank you






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default second or third match in vlookup() or Match()

Assuming all ranges start in Row 1
doesn't this do what your formula does?
remove the beginning row adjustment


Yes, but....

99 out of 100 people that use this type of formula don't understand what
ROW(...) is doing so using:

ROW(B1:B10)-MIN(ROW(B1:B10))+1

Is the most fool-proof method to get things to work properly. As an added
bonus, this expression also makes the formula robust against row insertions.

Some folks use: ROW(INDIRECT("1:"&ROWS(rng)))

The formula is already not very efficient on large data sets so adding
volatility to the mix just makes things worse.


--
Biff
Microsoft Excel MVP


"Rick Rothstein (MVP - VB)" wrote in
message ...
Assuming all ranges start in Row 1, doesn't this do what your formula
does?

=INDEX(B1:B10,SMALL(IF(A1:A10=D1,ROW(B1:B10)),n))

All I did was remove the beginning row adjustment from you formula, namely
this part...

-MIN(ROW(B1:B10))+1

Or were you assuming your formula would be copied down (I didn't get that
as a requirement from the OP's posting).

Rick


"T. Valko" wrote in message
...
Try this array formula** :

D1 = lookup value

=INDEX(B1:B10,SMALL(IF(A1:A10=D1,ROW(B1:B10)-MIN(ROW(B1:B10))+1),n))

Where n = the instance number you want to find.

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

--
Biff
Microsoft Excel MVP


"Dan" wrote in message
...
Is it possible to get the second or third match instead of the first?
Thank you






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MATCH Multiple Criteria & Return Previous / Penultimate Match Sam via OfficeKB.com Excel Worksheet Functions 27 October 6th 07 01:39 AM
index Match, or Vlookup Match.. news.transedge.com Excel Worksheet Functions 1 August 3rd 07 02:00 AM
index match array function-returning only first match, need last. Julie Olsen Excel Worksheet Functions 3 December 29th 06 12:50 AM
Lookup? Match? pulling rows from one spreadsheet to match a text f cjax Excel Worksheet Functions 3 July 21st 06 02:51 PM
When MATCH and v/hLOOKUP functions *FAIL* to match (but they should)... [email protected] Excel Worksheet Functions 2 April 6th 05 09:59 PM


All times are GMT +1. The time now is 04:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"