+ Reply to Thread
Results 1 to 6 of 6

How to Return the row# of the 2nd Occurrence using MATCH( ) Function?

  1. #1
    Registered User
    Join Date
    02-06-2014
    Location
    Cairo, Egypt
    MS-Off Ver
    Excel 2010
    Posts
    9

    How to Return the row# of the 2nd Occurrence using MATCH( ) Function?

    Dears,

    I know how to use MATCH() Function to return the row number of which the look-up value occurs, what I need to do is to return the row number of the second occurrence of this look-up value, is there any way to do that?
    Last edited by htawfik; 02-07-2014 at 02:16 AM.

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: How to Return the row# of the 2nd Occurrence using MATCH( ) Function?

    welcome to the forum. based on your title, the answer is no. you cannot use match. you can use an array formula with SMALL though. say your data is:
    Data Range
    A
    1
    2
    a
    3
    b
    4
    c
    5
    a
    6
    c

    MATCH would be:
    =MATCH("a",A2:A6,0)

    finding 2nd occurrence would be:
    =SMALL(IF(A2:A6="a",ROW(A2:A6)-ROW(A2)+1),2)

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    so if A2:A6 is "a", return the row number of A2:A6. it will give you
    {2;FALSE;FALSE;5;FALSE}
    what you need is 1 & 4. so minus the starting row using -ROW(A2)(i.e. 2) and add back 1

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: How to Return the row# of the 2nd Occurrence using MATCH( ) Function?

    If you have any problem in implementing the formula suggested by benishiryo, Please find the attached sheet to see how this works.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Registered User
    Join Date
    02-06-2014
    Location
    Cairo, Egypt
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: How to Return the row# of the 2nd Occurrence using MATCH( ) Function?

    It worked just fine. Thank you both

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: How to Return the row# of the 2nd Occurrence using MATCH( ) Function?

    Glad to help you. Thanks for the feedback.
    If you have got the answer, please mark your thread as solved.
    Moreover you may also click on * (star) to Add Reputation to those who have put their time and efforts to help you in this forum. This is another way to say thanks to them.

  6. #6
    Registered User
    Join Date
    02-06-2014
    Location
    Cairo, Egypt
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: How to Return the row# of the 2nd Occurrence using MATCH( ) Function?

    I have a problem, as when I started using the formula mentioned above by benishiryo, the file is slowly calculating now, 2-3 minutes to calculate the arrays.
    Given that the array is repeated 400 times in 1 column, any help?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 10-27-2010, 08:05 PM
  2. Return First Occurrence
    By ComradeBT in forum Excel General
    Replies: 12
    Last Post: 07-29-2010, 03:15 PM
  3. vlookup to return the nth occurrence
    By niyrho in forum Excel General
    Replies: 2
    Last Post: 07-29-2008, 02:53 PM
  4. Match Each Numeric occurrence and Return Individual Rows of Data
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-13-2005, 12:05 AM
  5. [SOLVED] Match Last Occurrence of two numbers and Return Date
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-05-2005, 08:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1