+ Reply to Thread
Results 1 to 9 of 9

Reverse HLOOKUP

  1. #1
    Registered User
    Join Date
    08-04-2006
    Posts
    55

    Exclamation Reverse HLOOKUP

    Hi there

    I have a spreadsheet in which I need to perform a reverse HLOOKUP. The spreadsheet is attached for viewing.

    I want a forumula in cell L2, which will look into cell K2 and if K2 is not empty, it will then look along the row to find the first cell that is not empty, then return the column name of that cell.

    So in row two, if case closed is a yes, i want it to return the column ref that is not empty, ie if 1st meeting is full, and report written and 2nd meeting, but business written is empty, then it should return '2nd meeting'.

    Any clues?
    Thanks - Brokovich.
    Attached Files Attached Files
    Last edited by Brokovich; 05-18-2007 at 04:25 AM.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444
    Hi,

    =IF(K2<>"",IF(ISERROR(INDEX(A1:F1,1,MATCH("",A2:F2,-1))),INDEX(A1:F1,1,MATCH(1,A2:F2,-1)),INDEX(A1:F1,1,MATCH("",A2:F2,-1))),"")

    Should do what you need, assuming that the "column names" are in row 1 and between columns A and F. Adjust the coloured ranges above as required.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Contributor WinteE's Avatar
    Join Date
    04-07-2007
    Location
    Netherlands
    Posts
    544
    Copy this code in a VBA module of your sheet, it will give you a user defined function.

    Please Login or Register  to view this content.
    The numbering of the columns starts in the first column of SearchRange.

    Succes,

    Erik
    Just keep it simple !


    http://www.excelguide.eu
    In English as well as in Dutch

  4. #4
    Registered User
    Join Date
    08-04-2006
    Posts
    55
    Thanks Sweep and WinteE, i tried both of those and neither worked unfortunately. i have now attached the example of the sheet (forgot the first time!) so maybe that will help??

  5. #5
    Forum Contributor WinteE's Avatar
    Join Date
    04-07-2007
    Location
    Netherlands
    Posts
    544
    Feel free to change the code.
    Last edited by WinteE; 05-18-2007 at 04:58 AM.

  6. #6
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444
    =if(k2<>"",if(iserror(index($f$1:$k$1,1,match(0,f2:k2,-1))),index($f$1:$k$1,1,match("",f2:k2,-1)),index($f$1:$k$1,1,match(0,f2:k2,-1))),"")

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Try this formula in K2 copied down

    =IF(K2="Yes",LOOKUP(2,1/(G2:J2<>""),G$1:J$1),"")

  8. #8
    Registered User
    Join Date
    08-04-2006
    Posts
    55
    Sweep, yours worked great, apart from on row 3, where it returns '1st Meeting Held' but it should return 'Report Written'....

  9. #9
    Registered User
    Join Date
    08-04-2006
    Posts
    55
    Daddylonglegs, yours worked perfectly!

    Thank you all for your help and assistance once again. You guys rock!

    Brokovich

+ 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