+ Reply to Thread
Results 1 to 19 of 19

Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

  1. #1
    Registered User
    Join Date
    08-21-2014
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    19

    Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Hello All,

    I'm attempting to figure out some sort of formula or function that will allow me to match a specific value in one sheet with a value in another sheet and then return the value that is in the top of the column it is in. I thought that maybe I would need to do some sort of VLOOKUP function but that won't work.. I looked into INDEX and MATCH but I'm completely clueless as to how to put it together. I'll attach the file that I'm using.. I want to be able to match the values in sheet A with values in sheet Master File. If the value occurs more than once in the Master File sheet then I would like for it to return the top value of that column as well.. and put it into the "Location" column. So If A13/4L150 is in the master file sheet then return the value of 4.17.3, 4.14.3, 4.13.2 etc etc... could this be done? Stocking.xlsx

    Thanks in advance!
    Last edited by dylanvv; 08-13-2015 at 01:47 PM.

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    E2=IFERROR(INDEX('Master File'!$1:$1,MIN(INDEX(('Master File'!$A$2:$TG$576<>$A$1&$A2)*10^10+COLUMN('Master File'!$A$2:$TG$576),0))),"")
    Please Login or Register  to view this content.
    Try this and copy towards down in all sheets
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    This seems to work for me.

    =IF(LARGE(INDEX(('Master File'!$B$2:$SV$50=A2)*(COLUMN($B$2:$SV$50)),),1)=0,"",INDEX('Master File'!$A$1:$SV$1,LARGE(INDEX(('Master File'!$B$2:$SV$50=A2)*(COLUMN($B$2:$SV$50)),),1)))

    It only pulls the one column. If you expect results from multiple columns, maybe VBA is the was to go.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    08-21-2014
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    19

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Hey ChemistB,

    This definitely works, I did want to get multiple columns but this still helps a lot with what I need to get done, I really appreciate it! How would I go about select a different sheet though? What needs to be changed exactly?..

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    This formula will work on any sheet where you are searching MasterFile for matches. If you want to search a different sheet, just change whereever it says Master File and adjust the data range and headers range.

  6. #6
    Registered User
    Join Date
    08-21-2014
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    19

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Okay excellent, would there be any way to include the formatting of the cell it finds in the master file once it's returned? Perhaps if it has a border around that cell to include it?

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Unfortunately, there are no formulas that pull the formatting along with the cell. You would require a VBA solution to do something like that or use conditional formatting if the formatting follows some sort of rules.

  8. #8
    Registered User
    Join Date
    08-21-2014
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    19

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Okay well thanks for your help! Much appreciated.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    I didn't download your file.

    See if this helps...

    Return ALL of the column headers if a column contains the number 1.

    Data Range
    A
    B
    C
    D
    E
    1
    Header1
    Header2
    Header3
    All Headers
    2
    11
    25
    72
    Header1
    3
    1
    34
    63
    Header3
    4
    99
    29
    1
    5
    90
    40
    37
    6


    This array formula** entered in E2:

    =IFERROR(INDEX(A$1:C$1,SMALL(IF(A$2:C$5=1,COLUMN(A2:C5)-COLUMN(A2)+1),ROWS(E$2:E2))),"")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy down until you get blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    The issue is that he has multiple (like 10 sometimes) duplicates under the same header so the formula would have to remove duplicate headers at the same time.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Content deleted.
    Last edited by Tony Valko; 08-14-2015 at 12:52 PM.

  12. #12
    Registered User
    Join Date
    08-21-2014
    Location
    Iowa
    MS-Off Ver
    2010
    Posts
    19

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Hey Tony, Not sure that's doing what I had intended sorry.

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    I guess I don't understand, then.

  14. #14
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    If I put a 1 in column B, it's only bringing back Header1 and header2 for some reason. Hmmmm

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Quote Originally Posted by ChemistB View Post
    If I put a 1 in column B, it's only bringing back Header1 and header2 for some reason. Hmmmm
    Yeah, disregard that post. Bugs!

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Ok, I think I have it working now.

    Data Range
    A
    B
    C
    D
    E
    5
    Header1
    Header2
    Header3
    ------
    Header1
    6
    59
    47
    1
    Header3
    7
    1
    91
    38
    8
    1
    35
    1


    This array formula** entered in E5:

    =INDEX(A$5:C$5,SMALL(IF(COUNTIF(OFFSET(A$6,,COLUMN(A6:C8)-COLUMN(A6),ROWS(A$6:C$8),1),1)>0,COLUMN(A6:C8)-COLUMN(A6)+1),ROWS(E$5:E5)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy down until you get blanks.

  17. #17
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Genius! Nice Job, Tony.

  18. #18
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Thanks!

  19. #19
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Match Values In Two Sheets And Return Value At The Top Of The Column It Was Matched In

    Dylan, if you're still out there, now that Tony has done all the hard work, I've modified his formula to work on the uploaded spreadsheet. In A!E2 copied down and across 3 columns (more if you think you'll need it), this Arrayed formula

    =IFERROR(INDEX('Master File'!$B$1:$SV$1,SMALL(IF(COUNTIF(OFFSET('Master File'!$B$2,,COLUMN($B$2:$SU$50)-COLUMN($B$2),ROWS($B$2:$SU$50),1),$A2)>0,COLUMN($B$2:$SU$50)-COLUMN($B$2)+1),COLUMNS($A$1:A$1))),"")

    See my attachment (I filtered SheetA column E to not show blanks.
    Attached Files Attached Files

+ 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: 9
    Last Post: 12-16-2013, 04:02 AM
  2. [SOLVED] Compare 2 sheets, match data in 1 column, update row in sheet 2 & add new rows not matched
    By Synchronicity in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-11-2013, 01:21 PM
  3. [SOLVED] Two Excel sheets trying to match text data and return the match from the second column!
    By bankcott in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-02-2013, 02:17 PM
  4. [SOLVED] Formula to match data ( multi column) in different sheets and return matching values
    By kangyao in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-17-2013, 08:49 PM
  5. [SOLVED] Formula to match data in different sheets ( multi column) and return matching values
    By kangyao in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-11-2013, 07:38 PM
  6. Replies: 4
    Last Post: 12-04-2012, 04:45 PM
  7. Match 2 columns in 2 sheets and return the 3rd column
    By swadson in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-16-2011, 04:36 PM

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