Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-05-31 Thread respuzy
Thanks guys I have figured it out with index and match and countif. Thanks
Sent from my BlackBerry® smartphone from Airtel Ghana

-Original Message-
From: resp...@gmail.com
Sender: excel-macros@googlegroups.com
Date: Thu, 31 May 2012 19:42:32 
To: 
Reply-To: excel-macros@googlegroups.com
Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance

Hello Excel Masters

if I have a list if names like below in column A and say I have corresponding 
different figures in column B.  
Hilary
Rajan
Maries
Noorain
Hilary
Rajan
Don
Kris
Asa

And so on and I want to return for instance the second occurance of hilary with 
its corresponding figure. Kindly help with formula. Thanks. 
Sent from my BlackBerry® smartphone from Airtel Ghana

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

--
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

--
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com


RE: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-05-31 Thread Asa Rossoff
Hi Hilary,

Mind sharing your solution with the group?

What came to mind for me was an array solution that uses small/row to
identify the second smallest row number for the matching name, and index to
retrieve the reference to the cell.

 

Here's a formula using that approach:

{

=INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceN
umber)-ROW(INDEX(NamesRange,1))+1)

}

 

If you were going to use many of these formulas, NamesRange was large, and
often there was not going to be a match (for example there was only one
occurrence and you were looking for the second), you could speed up the
formulas by use the following version that checks the count (using countif)
of matching names, and if the count is < OccurenceNumber (2 in your stated
question) it will skip the array formula and just return an error.  If there
will usually be a match, this would actually be slower since it has the
added countif.

{

=IF(COUNTIF(NamesRange,NameToFind)mailto:excel-macros@googlegroups.com]
On Behalf Of resp...@gmail.com
Sent: Thursday, May 31, 2012 2:01 PM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks guys I have figured it out with index and match and countif. Thanks

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-Original Message-

From:  <mailto:resp...@gmail.com> resp...@gmail.com

Sender:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Date: Thu, 31 May 2012 19:42:32 

To: < <mailto:excel-macros@googlegroups.com> excel-macros@googlegroups.com>

Reply-To:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hello Excel Masters

 

if I have a list if names like below in column A and say I have
corresponding different figures in column B.  

Hilary

Rajan

Maries

Noorain

Hilary

Rajan

Don

Kris

Asa

 

And so on and I want to return for instance the second occurance of hilary
with its corresponding figure. Kindly help with formula. Thanks. 

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-- 

FORUM RULES (986+ members already BANNED for violation)

 

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

 

2) Don't post a question in the thread of another member.

 

3) Don't post questions regarding breaking or bypassing any security
measure.

 

4) Acknowledge the responses you receive, good or bad.

 

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 

 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

 


--

To post to this group, send email to  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

 

To unsubscribe, send a blank email to
<mailto:excel-macros+unsubscr...@googlegroups.com>
excel-macros+unsubscr...@googlegroups.com

 

-- 

FORUM RULES (986+ members already BANNED for violation)

 

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

 

2) Don't post a question in the thread of another member.

 

3) Don't post questions regarding breaking or bypassing any security
measure.

 

4) Acknowledge the responses you receive, good or bad.

 

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 

 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

 


--

To post to this group, send email to  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

 

To unsubscribe, send a blank email to
<mailto:excel-macros+unsubscr...@googlegroups.com>
excel-macros+unsubscr...@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever p

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-01 Thread hilary lomotey
Thanks Asa

Attached is what i attempted doing, but after testing my formula this
morning with other examples i realised, its doesnt work for all, i will try
your now. thanks

On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:

> Hi Hilary,
>
> Mind sharing your solution with the group?
>
> What came to mind for me was an array solution that uses small/row to
> identify the second smallest row number for the matching name, and index to
> retrieve the reference to the cell.
>
> ** **
>
> Here's a formula using that approach:
>
> {
>
>
> =INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceNumber)-ROW(INDEX(NamesRange,1))+1)
> 
>
> }
>
> ** **
>
> If you were going to use many of these formulas, NamesRange was large, and
> often there was not going to be a match (for example there was only one
> occurrence and you were looking for the second), you could speed up the
> formulas by use the following version that checks the count (using countif)
> of matching names, and if the count is < OccurenceNumber (2 in your stated
> question) it will skip the array formula and just return an error.  If
> there will usually be a match, this would actually be slower since it has
> the added countif.
>
> {
>
>
> =IF(COUNTIF(NamesRange,NameToFind) 
>
> }
>
> ** **
>
> ** **
>
> Upon a little more thought, here is a non-array solution for finding
> exactly the 2nd occurrence (the array version would work for finding any
> specific occurrence).  It uses match to find the first occurrence, then
> another match to find the next occurrence. It should be faster---it has
> less work to do.  If there is no match it either returns an NA error or if
> the only match was on the very last row of the range, a REF error.
>
>
> =INDEX(NamesRange,MATCH(NameToFind,NamesRange,0)+MATCH(NameToFind,INDEX(NamesRange,MATCH(NameToFind,NamesRange,0)+1):INDEX(NamesRange,ROWS(NamesRange)),0))
> 
>
> ** **
>
> Asa
>
> ** **
>
> -Original Message-
> From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
> On Behalf Of resp...@gmail.com
> Sent: Thursday, May 31, 2012 2:01 PM
> To: excel-macros@googlegroups.com
> Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance
>
> ** **
>
> Thanks guys I have figured it out with index and match and countif. Thanks
> 
>
> Sent from my BlackBerry® smartphone from Airtel Ghana
>
> ** **
>
> -Original Message-
>
> From: resp...@gmail.com
>
> Sender: excel-macros@googlegroups.com
>
> Date: Thu, 31 May 2012 19:42:32 
>
> To: 
>
> Reply-To: excel-macros@googlegroups.com
>
> Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance
>
> ** **
>
> Hello Excel Masters
>
> ** **
>
> if I have a list if names like below in column A and say I have
> corresponding different figures in column B.  
>
> Hilary
>
> Rajan
>
> Maries
>
> Noorain
>
> Hilary
>
> Rajan
>
> Don
>
> Kris
>
> Asa
>
> ** **
>
> And so on and I want to return for instance the second occurance of hilary
> with its corresponding figure. Kindly help with formula. Thanks. 
>
> Sent from my BlackBerry® smartphone from Airtel Ghana
>
> ** **
>
> -- 
>
> FORUM RULES (986+ members already BANNED for violation)
>
> ** **
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> ** **
>
> 2) Don't post a question in the thread of another member.
>
> ** **
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> ** **
>
> 4) Acknowledge the responses you receive, good or bad.
>
> ** **
>
> 5)  Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited. 
>
> ** **
>
> NOTE  : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
> ** **
>
>
> --
> 
>
> To post to this group, send email to excel-macros@googlegroups.com
>
> ** **
>
> To unsubscribe, send a blank email to
> excel-macros+unsubscr...@googlegroups.com
>
> ** **
>
> -- 
>
> FORUM RULES (986+ members already BANNED for violati

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-01 Thread NOORAIN ANSARI
Hi Hilary,

It is possible without using countif or Helping column

Please try it

=INDEX($B$2:$B$10,SMALL(IF($A$2:$A$10=A14,ROW($B$2:$B$10),""),ROW($A$2))-1)

with ctrl+shfit+enter
It is also possible through Sumproudct and offset

See attached sheet.

-- 
Thanks & regards,
Noorain Ansari
www.noorainansari.com
www.excelmacroworld.blogspot.com

On Fri, Jun 1, 2012 at 1:51 PM, hilary lomotey  wrote:

> Thanks Asa
>
> Attached is what i attempted doing, but after testing my formula this
> morning with other examples i realised, its doesnt work for all, i will try
> your now. thanks
>
>
> On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:
>
>> Hi Hilary,
>>
>> Mind sharing your solution with the group?
>>
>> What came to mind for me was an array solution that uses small/row to
>> identify the second smallest row number for the matching name, and index to
>> retrieve the reference to the cell.
>>
>> ** **
>>
>> Here's a formula using that approach:
>>
>> {
>>
>>
>> =INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceNumber)-ROW(INDEX(NamesRange,1))+1)
>> 
>>
>> }
>>
>> ** **
>>
>> If you were going to use many of these formulas, NamesRange was large,
>> and often there was not going to be a match (for example there was only one
>> occurrence and you were looking for the second), you could speed up the
>> formulas by use the following version that checks the count (using countif)
>> of matching names, and if the count is < OccurenceNumber (2 in your stated
>> question) it will skip the array formula and just return an error.  If
>> there will usually be a match, this would actually be slower since it has
>> the added countif.
>>
>> {
>>
>>
>> =IF(COUNTIF(NamesRange,NameToFind)> 
>>
>> }
>>
>> ** **
>>
>> ** **
>>
>> Upon a little more thought, here is a non-array solution for finding
>> exactly the 2nd occurrence (the array version would work for finding any
>> specific occurrence).  It uses match to find the first occurrence, then
>> another match to find the next occurrence. It should be faster---it has
>> less work to do.  If there is no match it either returns an NA error or if
>> the only match was on the very last row of the range, a REF error.
>>
>>
>> =INDEX(NamesRange,MATCH(NameToFind,NamesRange,0)+MATCH(NameToFind,INDEX(NamesRange,MATCH(NameToFind,NamesRange,0)+1):INDEX(NamesRange,ROWS(NamesRange)),0))
>> 
>>
>> ** **
>>
>> Asa
>>
>> ** **
>>
>> -Original Message-
>> From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
>> On Behalf Of resp...@gmail.com
>> Sent: Thursday, May 31, 2012 2:01 PM
>> To: excel-macros@googlegroups.com
>> Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance
>>
>> ** **
>>
>> Thanks guys I have figured it out with index and match and countif. Thanks
>> 
>>
>> Sent from my BlackBerry® smartphone from Airtel Ghana
>>
>> ** **
>>
>> -Original Message-
>>
>> From: resp...@gmail.com
>>
>> Sender: excel-macros@googlegroups.com
>>
>> Date: Thu, 31 May 2012 19:42:32 
>>
>> To: 
>>
>> Reply-To: excel-macros@googlegroups.com
>>
>> Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance
>>
>> ** **
>>
>> Hello Excel Masters
>>
>> ** **
>>
>> if I have a list if names like below in column A and say I have
>> corresponding different figures in column B.  
>>
>> Hilary
>>
>> Rajan
>>
>> Maries
>>
>> Noorain
>>
>> Hilary
>>
>> Rajan
>>
>> Don
>>
>> Kris
>>
>> Asa
>>
>> ** **
>>
>> And so on and I want to return for instance the second occurance of
>> hilary with its corresponding figure. Kindly help with formula. Thanks. *
>> ***
>>
>> Sent from my BlackBerry® smartphone from Airtel Ghana
>>
>> ** **
>>
>> -- 
>>
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> ** **
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> ** **
>

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-01 Thread hilary lomotey
Hi Asa

Your formula is working to perfection, thanks a lot, just two quick
questions
Kindly explain this bit of the formula taking out "ROW(INDEX(NamesRange,1)"
from the entire formula

Are a Lecturer or some sort?, i always look at the way you explain every
problem that you tackle, its like a lecturer,


thanks


On Fri, Jun 1, 2012 at 8:21 AM, hilary lomotey  wrote:

> Thanks Asa
>
> Attached is what i attempted doing, but after testing my formula this
> morning with other examples i realised, its doesnt work for all, i will try
> your now. thanks
>
>
> On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:
>
>> Hi Hilary,
>>
>> Mind sharing your solution with the group?
>>
>> What came to mind for me was an array solution that uses small/row to
>> identify the second smallest row number for the matching name, and index to
>> retrieve the reference to the cell.
>>
>> ** **
>>
>> Here's a formula using that approach:
>>
>> {
>>
>>
>> =INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceNumber)-ROW(INDEX(NamesRange,1))+1)
>> 
>>
>> }
>>
>> ** **
>>
>> If you were going to use many of these formulas, NamesRange was large,
>> and often there was not going to be a match (for example there was only one
>> occurrence and you were looking for the second), you could speed up the
>> formulas by use the following version that checks the count (using countif)
>> of matching names, and if the count is < OccurenceNumber (2 in your stated
>> question) it will skip the array formula and just return an error.  If
>> there will usually be a match, this would actually be slower since it has
>> the added countif.
>>
>> {
>>
>>
>> =IF(COUNTIF(NamesRange,NameToFind)> 
>>
>> }
>>
>> ** **
>>
>> ** **
>>
>> Upon a little more thought, here is a non-array solution for finding
>> exactly the 2nd occurrence (the array version would work for finding any
>> specific occurrence).  It uses match to find the first occurrence, then
>> another match to find the next occurrence. It should be faster---it has
>> less work to do.  If there is no match it either returns an NA error or if
>> the only match was on the very last row of the range, a REF error.
>>
>>
>> =INDEX(NamesRange,MATCH(NameToFind,NamesRange,0)+MATCH(NameToFind,INDEX(NamesRange,MATCH(NameToFind,NamesRange,0)+1):INDEX(NamesRange,ROWS(NamesRange)),0))
>> 
>>
>> ** **
>>
>> Asa
>>
>> ** **
>>
>> -Original Message-
>> From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
>> On Behalf Of resp...@gmail.com
>> Sent: Thursday, May 31, 2012 2:01 PM
>> To: excel-macros@googlegroups.com
>> Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance
>>
>> ** **
>>
>> Thanks guys I have figured it out with index and match and countif. Thanks
>> 
>>
>> Sent from my BlackBerry® smartphone from Airtel Ghana
>>
>> ** **
>>
>> -Original Message-
>>
>> From: resp...@gmail.com
>>
>> Sender: excel-macros@googlegroups.com
>>
>> Date: Thu, 31 May 2012 19:42:32 
>>
>> To: 
>>
>> Reply-To: excel-macros@googlegroups.com
>>
>> Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance
>>
>> ** **
>>
>> Hello Excel Masters
>>
>> ** **
>>
>> if I have a list if names like below in column A and say I have
>> corresponding different figures in column B.  
>>
>> Hilary
>>
>> Rajan
>>
>> Maries
>>
>> Noorain
>>
>> Hilary
>>
>> Rajan
>>
>> Don
>>
>> Kris
>>
>> Asa
>>
>> ** **
>>
>> And so on and I want to return for instance the second occurance of
>> hilary with its corresponding figure. Kindly help with formula. Thanks. *
>> ***
>>
>> Sent from my BlackBerry® smartphone from Airtel Ghana
>>
>> ** **
>>
>> -- 
>>
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> ** **
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> ** **
>>
>> 2) Don't post

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-01 Thread Haseeb A
Hello Hilary,
 
If you want to return the exact 2nd occurrance value, you can use VLOOKUP 
like this,
 
=VLOOKUP(A14,INDEX(A:A,MATCH(A14,A:A,0)+1):INDEX(B:B,65536),2,0)
 
Regards,
Haseeb

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

--
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-01 Thread hilary lomotey
Thanks Haseeb, will try now, very grateful

On Fri, Jun 1, 2012 at 3:53 PM, Haseeb A  wrote:

> Hello Hilary,
>
> If you want to return the exact 2nd occurrance value, you can use VLOOKUP
> like this,
>
> =VLOOKUP(A14,INDEX(A:A,MATCH(A14,A:A,0)+1):INDEX(B:B,65536),2,0)
>
> Regards,
> Haseeb
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> --
> To post to this group, send email to excel-macros@googlegroups.com
>
> To unsubscribe, send a blank email to
> excel-macros+unsubscr...@googlegroups.com
>

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

--
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com

RE: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-03 Thread Rajan_Verma
=INDEX($A$1:$B$10,MAX(--($A$1:$A$10=A2)*ROW($A$1:$A$10)),2) with CSE

 

 

Regards

Rajan verma

+91 7838100659 [IM-Gtalk]

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of hilary lomotey
Sent: 01 June 2012 1:51
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks Asa

 

Attached is what i attempted doing, but after testing my formula this
morning with other examples i realised, its doesnt work for all, i will try
your now. thanks 

On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:

Hi Hilary,

Mind sharing your solution with the group?

What came to mind for me was an array solution that uses small/row to
identify the second smallest row number for the matching name, and index to
retrieve the reference to the cell.

 

Here's a formula using that approach:

{

=INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceN
umber)-ROW(INDEX(NamesRange,1))+1)

}

 

If you were going to use many of these formulas, NamesRange was large, and
often there was not going to be a match (for example there was only one
occurrence and you were looking for the second), you could speed up the
formulas by use the following version that checks the count (using countif)
of matching names, and if the count is < OccurenceNumber (2 in your stated
question) it will skip the array formula and just return an error.  If there
will usually be a match, this would actually be slower since it has the
added countif.

{

=IF(COUNTIF(NamesRange,NameToFind)mailto:excel-macros@googlegroups.com]
On Behalf Of resp...@gmail.com
Sent: Thursday, May 31, 2012 2:01 PM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks guys I have figured it out with index and match and countif. Thanks

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-Original Message-

From:  <mailto:resp...@gmail.com> resp...@gmail.com

Sender:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Date: Thu, 31 May 2012 19:42:32 

To: < <mailto:excel-macros@googlegroups.com> excel-macros@googlegroups.com>

Reply-To:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hello Excel Masters

 

if I have a list if names like below in column A and say I have
corresponding different figures in column B.  

Hilary

Rajan

Maries

Noorain

Hilary

Rajan

Don

Kris

Asa

 

And so on and I want to return for instance the second occurance of hilary
with its corresponding figure. Kindly help with formula. Thanks. 

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-- 

FORUM RULES (986+ members already BANNED for violation)

 

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

 

2) Don't post a question in the thread of another member.

 

3) Don't post questions regarding breaking or bypassing any security
measure.

 

4) Acknowledge the responses you receive, good or bad.

 

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 

 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

 


--

To post to this group, send email to  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

 

To unsubscribe, send a blank email to
<mailto:excel-macros+unsubscr...@googlegroups.com>
excel-macros+unsubscr...@googlegroups.com

 

-- 

FORUM RULES (986+ members already BANNED for violation)

 

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

 

2) Don't post a question in the thread of another member.

 

3) Don't post questions regarding breaking or bypassing any security
measure.

 

4) Acknowledge the responses you receive, good or bad.

 

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 

 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

 


--

To post to this group, send email to  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

 

To unsubscribe, send a blank email to
<mailto:excel-macros+unsubscr...@googlegroups.com>
excel-macros+unsubscr...@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) 

RE: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-03 Thread Asa Rossoff
Hi Hilary,

INDEX(NamesRange,1) returns the first row of the range (which is a single
cell since the range is only one column wide).

Put that inside a ROW() function and you get the first row number.

 

Equally effective would be specifying the first cell in NamesRange instead:

ROW(FirstCellInNamesRange)

 

For example, if NamesRange is $A$2:$A$13:

INDEX(NamesRange,1) is $A$2

ROW(Index(NamesRange,1)) is ROW($A$2) which is 2.

 

You might be confused if you think INDEX returns the value of a cell.  If
INDEX(NamesRange,1) refers to $A$2 and cell A2 contains "Hilary", then you
might expect ROW(INDEX(NamesRange,1)) to be equivalent to ROW("Hilary").
which clearly would not work.

 

The reason ROW(INDEX(NamesRange,1)) is equivalent to ROW($A$2) instead is
because INDEX is one of the three main functions that can return cell
references, and can be used in place of cell references anywhere cell
references are expected (the other two are OFFSET and INDIRECT).  In a
formula result, a cell reference is displayed on the worksheet by the value
of the referenced cells, so the end result is sometimes the same.

 

The reason I used Row(Index(NamesRange,1)) in the formula instead of
Row($A$2) or Row(FirstCellInNamesRange) was primarily that it would allow
you to use defined names for your ranges without any changes to the formula,
or a redundant defined name to refer to the first cell/first row in
NamesRange.

 

 

No, I'm not a lectururer.  I like teaching (informally), and I like words,
though.   I take it as a complement that you might think so, thanks :).  I'm
impressed with your dashboards and workbooks that I've seen so far.  I only
wish I was involved in finance -- I'd ask to use them myself.

 

 

Two of my previously suggested formulas, with range references substituted
for range names:

1.   Standard formula (faster than the array formula, also it will work
with wildcards):
=INDEX($B$2:$B$13,MATCH($A$17,$A$2:$A$13,0)+MATCH($A$17,INDEX($A$2:$A$13,MAT
CH($A$17,$A$2:$A$13,0)+1):INDEX($A$2:$A$13,ROWS($A$2:$A$13)),0))

2.   Array formula:
=INDEX($B$2:$B$13,SMALL(IF($A$2:$A$13=$A$17,ROW($A$2:$A$13)),2)-ROW($A$2)+1)

 

Asa

 

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of hilary lomotey
Sent: Friday, June 01, 2012 1:34 AM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hi Asa

 

Your formula is working to perfection, thanks a lot, just two quick
questions

Kindly explain this bit of the formula taking out "ROW(INDEX(NamesRange,1)"
from the entire formula

 

Are a Lecturer or some sort?, i always look at the way you explain every
problem that you tackle, its like a lecturer,

 

 

thanks 



On Fri, Jun 1, 2012 at 8:21 AM, hilary lomotey  wrote:

Thanks Asa

 

Attached is what i attempted doing, but after testing my formula this
morning with other examples i realised, its doesnt work for all, i will try
your now. thanks 

 

On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:

Hi Hilary,

Mind sharing your solution with the group?

What came to mind for me was an array solution that uses small/row to
identify the second smallest row number for the matching name, and index to
retrieve the reference to the cell.

 

Here's a formula using that approach:

{

=INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceN
umber)-ROW(INDEX(NamesRange,1))+1)

}

 

If you were going to use many of these formulas, NamesRange was large, and
often there was not going to be a match (for example there was only one
occurrence and you were looking for the second), you could speed up the
formulas by use the following version that checks the count (using countif)
of matching names, and if the count is < OccurenceNumber (2 in your stated
question) it will skip the array formula and just return an error.  If there
will usually be a match, this would actually be slower since it has the
added countif.

{

=IF(COUNTIF(NamesRange,NameToFind)mailto:excel-macros@googlegroups.com]
On Behalf Of resp...@gmail.com
Sent: Thursday, May 31, 2012 2:01 PM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks guys I have figured it out with index and match and countif. Thanks

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-Original Message-

From:  <mailto:resp...@gmail.com> resp...@gmail.com

Sender:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Date: Thu, 31 May 2012 19:42:32 

To: < <mailto:excel-macros@googlegroups.com> excel-macros@googlegroups.com>

Reply-To:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hello Excel Masters

 

if I have a list if names like below in column A and say I have
corresponding different figures in column B.  

H

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-03 Thread respuzy
Thanks Raj. Will try this as well
Sent from my BlackBerry® smartphone from Airtel Ghana

-Original Message-
From: "Rajan_Verma" 
Sender: excel-macros@googlegroups.com
Date: Sun, 3 Jun 2012 12:33:08 
To: 
Reply-To: excel-macros@googlegroups.com
Subject: RE: $$Excel-Macros$$ Lookup and return 2nd occurrance

=INDEX($A$1:$B$10,MAX(--($A$1:$A$10=A2)*ROW($A$1:$A$10)),2) with CSE

 

 

Regards

Rajan verma

+91 7838100659 [IM-Gtalk]

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of hilary lomotey
Sent: 01 June 2012 1:51
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks Asa

 

Attached is what i attempted doing, but after testing my formula this
morning with other examples i realised, its doesnt work for all, i will try
your now. thanks 

On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:

Hi Hilary,

Mind sharing your solution with the group?

What came to mind for me was an array solution that uses small/row to
identify the second smallest row number for the matching name, and index to
retrieve the reference to the cell.

 

Here's a formula using that approach:

{

=INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceN
umber)-ROW(INDEX(NamesRange,1))+1)

}

 

If you were going to use many of these formulas, NamesRange was large, and
often there was not going to be a match (for example there was only one
occurrence and you were looking for the second), you could speed up the
formulas by use the following version that checks the count (using countif)
of matching names, and if the count is < OccurenceNumber (2 in your stated
question) it will skip the array formula and just return an error.  If there
will usually be a match, this would actually be slower since it has the
added countif.

{

=IF(COUNTIF(NamesRange,NameToFind)mailto:excel-macros@googlegroups.com]
On Behalf Of resp...@gmail.com
Sent: Thursday, May 31, 2012 2:01 PM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks guys I have figured it out with index and match and countif. Thanks

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-Original Message-

From:  <mailto:resp...@gmail.com> resp...@gmail.com

Sender:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Date: Thu, 31 May 2012 19:42:32 

To: < <mailto:excel-macros@googlegroups.com> excel-macros@googlegroups.com>

Reply-To:  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

Subject: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hello Excel Masters

 

if I have a list if names like below in column A and say I have
corresponding different figures in column B.  

Hilary

Rajan

Maries

Noorain

Hilary

Rajan

Don

Kris

Asa

 

And so on and I want to return for instance the second occurance of hilary
with its corresponding figure. Kindly help with formula. Thanks. 

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-- 

FORUM RULES (986+ members already BANNED for violation)

 

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

 

2) Don't post a question in the thread of another member.

 

3) Don't post questions regarding breaking or bypassing any security
measure.

 

4) Acknowledge the responses you receive, good or bad.

 

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 

 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

 


--

To post to this group, send email to  <mailto:excel-macros@googlegroups.com>
excel-macros@googlegroups.com

 

To unsubscribe, send a blank email to
<mailto:excel-macros+unsubscr...@googlegroups.com>
excel-macros+unsubscr...@googlegroups.com

 

-- 

FORUM RULES (986+ members already BANNED for violation)

 

1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.

 

2) Don't post a question in the thread of another member.

 

3) Don't post questions regarding breaking or bypassing any security
measure.

 

4) Acknowledge the responses you receive, good or bad.

 

5)  Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 

 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.

 


--

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-03 Thread respuzy
Thanks for the explanation. What I like abt this formula is it actually picks 
not only the 2nd occurance but the last occurance which I think might be useful 
going forward. Thanks again
Sent from my BlackBerry® smartphone from Airtel Ghana

-Original Message-
From: "Asa Rossoff" 
Sender: excel-macros@googlegroups.com
Date: Sun, 3 Jun 2012 02:42:58 
To: 
Reply-To: excel-macros@googlegroups.com
Subject: RE: $$Excel-Macros$$ Lookup and return 2nd occurrance

Hi Hilary,

INDEX(NamesRange,1) returns the first row of the range (which is a single
cell since the range is only one column wide).

Put that inside a ROW() function and you get the first row number.

 

Equally effective would be specifying the first cell in NamesRange instead:

ROW(FirstCellInNamesRange)

 

For example, if NamesRange is $A$2:$A$13:

INDEX(NamesRange,1) is $A$2

ROW(Index(NamesRange,1)) is ROW($A$2) which is 2.

 

You might be confused if you think INDEX returns the value of a cell.  If
INDEX(NamesRange,1) refers to $A$2 and cell A2 contains "Hilary", then you
might expect ROW(INDEX(NamesRange,1)) to be equivalent to ROW("Hilary").
which clearly would not work.

 

The reason ROW(INDEX(NamesRange,1)) is equivalent to ROW($A$2) instead is
because INDEX is one of the three main functions that can return cell
references, and can be used in place of cell references anywhere cell
references are expected (the other two are OFFSET and INDIRECT).  In a
formula result, a cell reference is displayed on the worksheet by the value
of the referenced cells, so the end result is sometimes the same.

 

The reason I used Row(Index(NamesRange,1)) in the formula instead of
Row($A$2) or Row(FirstCellInNamesRange) was primarily that it would allow
you to use defined names for your ranges without any changes to the formula,
or a redundant defined name to refer to the first cell/first row in
NamesRange.

 

 

No, I'm not a lectururer.  I like teaching (informally), and I like words,
though.   I take it as a complement that you might think so, thanks :).  I'm
impressed with your dashboards and workbooks that I've seen so far.  I only
wish I was involved in finance -- I'd ask to use them myself.

 

 

Two of my previously suggested formulas, with range references substituted
for range names:

1.   Standard formula (faster than the array formula, also it will work
with wildcards):
=INDEX($B$2:$B$13,MATCH($A$17,$A$2:$A$13,0)+MATCH($A$17,INDEX($A$2:$A$13,MAT
CH($A$17,$A$2:$A$13,0)+1):INDEX($A$2:$A$13,ROWS($A$2:$A$13)),0))

2.   Array formula:
=INDEX($B$2:$B$13,SMALL(IF($A$2:$A$13=$A$17,ROW($A$2:$A$13)),2)-ROW($A$2)+1)

 

Asa

 

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of hilary lomotey
Sent: Friday, June 01, 2012 1:34 AM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hi Asa

 

Your formula is working to perfection, thanks a lot, just two quick
questions

Kindly explain this bit of the formula taking out "ROW(INDEX(NamesRange,1)"
from the entire formula

 

Are a Lecturer or some sort?, i always look at the way you explain every
problem that you tackle, its like a lecturer,

 

 

thanks 



On Fri, Jun 1, 2012 at 8:21 AM, hilary lomotey  wrote:

Thanks Asa

 

Attached is what i attempted doing, but after testing my formula this
morning with other examples i realised, its doesnt work for all, i will try
your now. thanks 

 

On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:

Hi Hilary,

Mind sharing your solution with the group?

What came to mind for me was an array solution that uses small/row to
identify the second smallest row number for the matching name, and index to
retrieve the reference to the cell.

 

Here's a formula using that approach:

{

=INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRange)),OccurenceN
umber)-ROW(INDEX(NamesRange,1))+1)

}

 

If you were going to use many of these formulas, NamesRange was large, and
often there was not going to be a match (for example there was only one
occurrence and you were looking for the second), you could speed up the
formulas by use the following version that checks the count (using countif)
of matching names, and if the count is < OccurenceNumber (2 in your stated
question) it will skip the array formula and just return an error.  If there
will usually be a match, this would actually be slower since it has the
added countif.

{

=IF(COUNTIF(NamesRange,NameToFind)mailto:excel-macros@googlegroups.com]
On Behalf Of resp...@gmail.com
Sent: Thursday, May 31, 2012 2:01 PM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks guys I have figured it out with index and match and countif. Thanks

Sent from my BlackBerryR smartphone from Airtel Ghana

 

-Original Message-

From:  <mailto:resp...@gmail.com> resp...@gmail.com

Sender:  <mailt

RE: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-03 Thread Asa Rossoff
Ah, I didn't realize what you had done in the sample file.  You looked up
the last occurrence.. Yes.  My formula could be reduced to
INDEX(what,SMALL(matching ROW,occurrence#)). but if you want the last
occurrence, it's better to use INDEX(what,MAX(matching ROW)) .. maybe Rajan
posted that suggestion, actually.

=INDEX($B$2:$B$13,MAX(IF(names=$A$17,ROW(names)))-ROW(INDEX(names,1))+1)

Simplified:

=INDEX($B$2:$B$13,MAX(IF(names=$A$17,ROW(names)))-ROW($A$2)+1)

In instances where the names range will definitely start on row 2, you can
use:

=INDEX($B$2:$B$13,MAX(IF(names=$A$17,ROW(names)))-1)

 

If you wanted the second to last match, you should still not use COUNTIF in
this formula.  In that case, you could substitute LARGE for SMALL:

=INDEX($B$2:$B$13,LARGE(IF(names=$A$17,ROW(names)),2)-1)

 

CSE all.

 

Asa

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of resp...@gmail.com
Sent: Sunday, June 03, 2012 4:23 AM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Thanks for the explanation. What I like abt this formula is it actually
picks not only the 2nd occurance but the last occurance which I think might
be useful going forward. Thanks again

Sent from my BlackBerryR smartphone from Airtel Ghana

  _  

From: "Asa Rossoff"  

Sender: excel-macros@googlegroups.com 

Date: Sun, 3 Jun 2012 02:42:58 -0700

To: 

ReplyTo: excel-macros@googlegroups.com 

Subject: RE: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hi Hilary,

INDEX(NamesRange,1) returns the first row of the range (which is a single
cell since the range is only one column wide).

Put that inside a ROW() function and you get the first row number.

 

Equally effective would be specifying the first cell in NamesRange instead:

ROW(FirstCellInNamesRange)

 

For example, if NamesRange is $A$2:$A$13:

INDEX(NamesRange,1) is $A$2

ROW(Index(NamesRange,1)) is ROW($A$2) which is 2.

 

You might be confused if you think INDEX returns the value of a cell.  If
INDEX(NamesRange,1) refers to $A$2 and cell A2 contains "Hilary", then you
might expect ROW(INDEX(NamesRange,1)) to be equivalent to ROW("Hilary").
which clearly would not work.

 

The reason ROW(INDEX(NamesRange,1)) is equivalent to ROW($A$2) instead is
because INDEX is one of the three main functions that can return cell
references, and can be used in place of cell references anywhere cell
references are expected (the other two are OFFSET and INDIRECT).  In a
formula result, a cell reference is displayed on the worksheet by the value
of the referenced cells, so the end result is sometimes the same.

 

The reason I used Row(Index(NamesRange,1)) in the formula instead of
Row($A$2) or Row(FirstCellInNamesRange) was primarily that it would allow
you to use defined names for your ranges without any changes to the formula,
or a redundant defined name to refer to the first cell/first row in
NamesRange.

 

 

No, I'm not a lectururer.  I like teaching (informally), and I like words,
though.   I take it as a complement that you might think so, thanks :).  I'm
impressed with your dashboards and workbooks that I've seen so far.  I only
wish I was involved in finance -- I'd ask to use them myself.

 

 

Two of my previously suggested formulas, with range references substituted
for range names:

1.   Standard formula (faster than the array formula, also it will work
with wildcards):
=INDEX($B$2:$B$13,MATCH($A$17,$A$2:$A$13,0)+MATCH($A$17,INDEX($A$2:$A$13,MAT
CH($A$17,$A$2:$A$13,0)+1):INDEX($A$2:$A$13,ROWS($A$2:$A$13)),0))

2.   Array formula:
=INDEX($B$2:$B$13,SMALL(IF($A$2:$A$13=$A$17,ROW($A$2:$A$13)),2)-ROW($A$2)+1)

 

Asa

 

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of hilary lomotey
Sent: Friday, June 01, 2012 1:34 AM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

 

Hi Asa

 

Your formula is working to perfection, thanks a lot, just two quick
questions

Kindly explain this bit of the formula taking out "ROW(INDEX(NamesRange,1)"
from the entire formula

 

Are a Lecturer or some sort?, i always look at the way you explain every
problem that you tackle, its like a lecturer,

 

 

thanks 

On Fri, Jun 1, 2012 at 8:21 AM, hilary lomotey  wrote:

Thanks Asa

 

Attached is what i attempted doing, but after testing my formula this
morning with other examples i realised, its doesnt work for all, i will try
your now. thanks 

 

On Fri, Jun 1, 2012 at 1:06 AM, Asa Rossoff  wrote:

Hi Hilary,

Mind sharing your solution with the group?

What came to mind for me was an array solution that uses small/row to
identify the second smallest row number for the matching name, and index to
retrieve the reference to the cell.

 

Here's a formula using that approach:

{

=INDEX(NamesRange,SMALL(IF(NamesRange=NameToFind,ROW(NamesRan

Re: $$Excel-Macros$$ Lookup and return 2nd occurrance

2012-06-04 Thread hilary lomotey
thanks Asa,

i will apply these instead, but quick question, the countif works so why
are you saying i should avoid it. thanks

On Sun, Jun 3, 2012 at 9:53 PM, Asa Rossoff  wrote:

> Ah, I didn't realize what you had done in the sample file.  You looked up
> the last occurrence.. Yes.  My formula could be reduced to
> INDEX(what,SMALL(matching ROW,occurrence#))… but if you want the last
> occurrence, it's better to use INDEX(what,MAX(matching ROW)) .. maybe Rajan
> posted that suggestion, actually.
>
> =INDEX($B$2:$B$13,*MAX(*IF(names=$A$17,ROW(names))*)*
> -ROW(INDEX(names,1))+1)
>
> Simplified:
>
> =INDEX($B$2:$B$13,MAX(IF(names=$A$17,ROW(names)))-ROW($A$2)+1)
>
> In instances where the names range will definitely start on row 2, you can
> use:
>
> =INDEX($B$2:$B$13,MAX(IF(names=$A$17,ROW(names)))-1)
>
> ** **
>
> If you wanted the second to last match, you should still not use COUNTIF
> in this formula.  In that case, you could substitute LARGE for SMALL:
>
> =INDEX($B$2:$B$13,*LARGE(*IF(names=$A$17,ROW(names))*,*2*)*-1)
>
> ** **
>
> CSE all.
>
> ** **
>
> Asa
>
> ** **
>
> *From:* excel-macros@googlegroups.com [mailto:
> excel-macros@googlegroups.com] *On Behalf Of *resp...@gmail.com
> *Sent:* Sunday, June 03, 2012 4:23 AM
>
> *To:* excel-macros@googlegroups.com
> *Subject:* Re: $$Excel-Macros$$ Lookup and return 2nd occurrance
>
> ** **
>
> Thanks for the explanation. What I like abt this formula is it actually
> picks not only the 2nd occurance but the last occurance which I think might
> be useful going forward. Thanks again
>
> Sent from my BlackBerry® smartphone from Airtel Ghana
> --
>
> *From: *"Asa Rossoff"  
>
> *Sender: *excel-macros@googlegroups.com ****
>
> *Date: *Sun, 3 Jun 2012 02:42:58 -0700
>
> *To: *
>
> *ReplyTo: *excel-macros@googlegroups.com 
>
> *Subject: *RE: $$Excel-Macros$$ Lookup and return 2nd occurrance
>
> ** **
>
> Hi Hilary,
>
> *INDEX(*NamesRange,1*)* returns the first row of the range (which is a
> single cell since the range is only one column wide).
>
> Put that inside a *ROW()* function and you get the first row number.
>
> ** **
>
> Equally effective would be specifying the first cell in NamesRangeinstead:
> 
>
> ROW(*FirstCellInNamesRange*)
>
> ** **
>
> *For example, if **NamesRange** is **$A$2:$A$13**:*
>
> *INDEX(*NamesRange,1*)* is *$A$2*
>
> *ROW(*Index(NamesRange,1)*)* is *ROW(*$A$2*)* which is *2*.
>
> ** **
>
> You might be confused if you think INDEX returns the value of a cell.  *If
> **INDEX(NamesRange,1)** refers to **$A$2** and cell **A2** contains "**
> Hilary**",* then you might expect ROW(INDEX(NamesRange,1)) to be
> equivalent to ROW("Hilary")… which clearly would not work.
>
> ** **
>
> The reason ROW(INDEX(NamesRange,1)) is equivalent to ROW($A$2) instead is
> because INDEX is one of the three main functions that can return cell
> references, and can be used in place of cell references anywhere cell
> references are expected (the other two are OFFSET and INDIRECT).  In a
> formula result, a cell reference is displayed on the worksheet by the value
> of the referenced cells, so the end result is sometimes the same.
>
> ** **
>
> The reason I used Row(Index(NamesRange,1)) in the formula instead of
> Row($A$2) or Row(FirstCellInNamesRange) was primarily that it would allow
> you to use defined names for your ranges without any changes to the
> formula, or a redundant defined name to refer to the first cell/first row
> in NamesRange.
>
> ** **
>
> ** **
>
> No, I'm not a lectururer.  I like teaching (informally), and I like words,
> though.   I take it as a complement that you might think so, thanks :).
> I'm impressed with your dashboards and workbooks that I've seen so far.  I
> only wish I was involved in finance -- I'd ask to use them myself.
>
> ** **
>
> ** **
>
> *Two of my previously suggested formulas, with range references
> substituted for range names:*
>
> **1.   **Standard formula (faster than the array formula, also it
> will work with wildcards):
>
> =INDEX($B$2:$B$13,MATCH($A$17,$A$2:$A$13,0)+MATCH($A$17,INDEX($A$2:$A$13,MATCH($A$17,$A$2:$A$13,0)+1):INDEX($A$2:$A$13,ROWS($A$2:$A$13)),0))
> 
>
> **2.   **Array formula:
>
> =INDEX($B$2:$B$13,SMALL(IF($A$2:$A$13=$A$17,ROW($A$2:$A$13)),2)-ROW($A$2)+1)
> 
>
> ** **
>
> Asa
>
> ** **
>
> ** **
>
> *From:* excel-macros@googlegroups.com [