+ Reply to Thread
Results 1 to 3 of 3

Index Match row value and nth occurrence of header

  1. #1
    Registered User
    Join Date
    03-03-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    39

    Index Match row value and nth occurrence of header

    I am getting muddled within my index find formulas.

    I have the following formula which matches my lookup value to a particular header and returns the intersecting value:
    =INDEX('[Workbook.xls]Jan'!A:CA,MATCH("Smith, John",'[Workbook.xls]Jan'!B:B,0),MATCH("Compliance Failures",'[Workbook.xls]Jan'!2:2,0))


    However, one of these headers (Compliance Failures) appears 4 times in my indexed ranged.
    Since I need to obtain the value in each of these 4 columns individually, how can i modify the above formula to look in the relevant column range each time?

    headers.png

    ps:
    Unfortunately I am not able to amend the source workbook in any way.
    I have chosen to use index/match as two versions of this document will be used and the columns I need to match to can move depending on the version - I found this the easiest way to ensure I it's as flexible as it can be without VBA. But I am open to suggestions...

    Thanks all, again!

  2. #2
    Registered User
    Join Date
    03-19-2013
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Index Match row value and nth occurrence of header

    =SMALL(IF('[Workbook.xls]Jan'!2:2="Compliance Failures",COLUMN('[Workbook.xls]Jan'!2:2)),1)
    Will return the column number of the first occurrence of the header "Compliance Failures".

    =SMALL(IF('[Workbook.xls]Jan'!2:2="Compliance Failures",COLUMN('[Workbook.xls]Jan'!2:2)),2)
    Will return the column number of the second occurrence of the header "Compliance Failures" and so on.

    You will need to enter them as array formulae i.e. press CTRL + SHIFT + ENTER rather than just ENTER as you would with an ordinary formula.

    You should be able to use this within your index formula but as I'm not sure of exactly how your spreadsheets work I won't attempt to write the whole formula for you.

    Perhaps someone else can help you there...

    Hope this helps, good luck.

  3. #3
    Registered User
    Join Date
    03-03-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Index Match row value and nth occurrence of header

    Hi Alex - thanks for looking at this.
    I have already looked at implementing the method mentioned -sorry I should have said.

    The problem I have is that the index formula quoted in my original post is dynamically constructed in VBA using several strings based on a users input.
    Once it has all of the user input needed it combines the various strings together and then inputs them into appropriate cells (i.e. range("a1").formula = mystring).

    Apologies, I should have said before but I wanted to simplify the post as much as possible.

    If anyone has a vba function to find the nth occurrence, that i could call in the match function this would be perfect.
    I'm stuck

    Thanks again for your help Alex.

    Edit: I suppose I could dynamically enter the array formula into a hidden column using vba, then use the result in my index formula.
    i.e. =INDEX('[Workbook.xls]Jan'!A:CA,MATCH("Smith, John",'[Workbook.xls]Jan'!B:B,0),arrayformularesult)
    Last edited by dm@stams; 03-22-2013 at 05:51 PM. Reason: Lightbulb

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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