+ Reply to Thread
Results 1 to 7 of 7

Find / Match a cell value to another cell and return all column values

  1. #1
    Registered User
    Join Date
    10-21-2010
    Location
    Portugal
    MS-Off Ver
    Office 365 & Google Sheets
    Posts
    23

    Unhappy Find / Match a cell value to another cell and return all column values

    Hi.

    I'm trying to make a formula to find/match a cell value to another cell and return column values.

    Example:

    Sheet 1 / Cell A1: "Name"

    I want to find in sheet 2 a cell with text "Name" and return all values above that cell (all column)... It is possible?

    Im trying to use a HLOOKUP but not always working as I want.

    Could anyone please help me?

    Thank you.
    Last edited by nupema; 09-17-2012 at 09:14 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520

    Re: Find / Match a cell value to another cell and return all column values

    One interp ..
    Assume the name in Sheet1's A1 can be found uniquely in col B in Sheet2
    In Sheet1,
    Put this in B1:
    =OFFSET(Sheet2!$B$1,MATCH(A$1,Sheet2!B:B,0)-ROWS($1:1)-1,)
    Copy down until you get #REF!
    The above will return all the col B values above the name, in reverse order
    ------
    Success? Celebrato, hit the star at the bottom left of my response

  3. #3
    Registered User
    Join Date
    10-21-2010
    Location
    Portugal
    MS-Off Ver
    Office 365 & Google Sheets
    Posts
    23

    Re: Find / Match a cell value to another cell and return all column values

    Hi, thanks for your help!

    I upload a file (better this way), please see attachment.

    Kind regards.
    Attached Files Attached Files

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Find / Match a cell value to another cell and return all column values

    Say Sheet2 has values from A1 thru Z100. First enter the following User Defined Function:

    Please Login or Register  to view this content.
    Then pick a cell in Sheet1 and enter:

    =GetValues(A1,Sheet2!A1:Z100) to display all the non-blank values above the found cell.


    User Defined Functions (UDFs) are very easy to install and use:

    1. ALT-F11 brings up the VBE window
    2. ALT-I
    ALT-M opens a fresh module
    3. paste the stuff in and close the VBE window

    If you save the workbook, the UDF will be saved with it.

    To remove the UDF:

    1. bring up the VBE window as above
    2. clear the code out
    3. close the VBE window

    To use the UDF from Excel:

    =myfunction(A1)

    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    or

    http://www.cpearson.com/excel/Writin...ionsInVBA.aspx
    for specifics on UDFs
    Gary's Student

  5. #5
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520

    Re: Find / Match a cell value to another cell and return all column values

    In Sheet2,
    Put in A2: =OFFSET(Sheet1!$A$1,ROWS($1:1),MATCH(A$1,Sheet1!$1:$1,0)-1)
    Copy across and fill down as required
    ------
    Success? Celebrate it, hit the star at the bottom left of my response

  6. #6
    Registered User
    Join Date
    10-21-2010
    Location
    Portugal
    MS-Off Ver
    Office 365 & Google Sheets
    Posts
    23

    Re: Find / Match a cell value to another cell and return all column values

    Solved!!! Thank you!


    Quote Originally Posted by Max, Singapore View Post
    In Sheet2,
    Put in A2: =OFFSET(Sheet1!$A$1,ROWS($1:1),MATCH(A$1,Sheet1!$1:$1,0)-1)
    Copy across and fill down as required
    ------
    Success? Celebrate it, hit the star at the bottom left of my response
    Attached Files Attached Files
    Last edited by nupema; 09-17-2012 at 11:04 AM.

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Find / Match a cell value to another cell and return all column values

    @ nupema

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as an infrequent user of the forum, you may have forgotten (or may not be aware) that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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