SOLVED

I really need a help with finding & matching data from two different sheets.

%3CLINGO-SUB%20id%3D%22lingo-sub-1894907%22%20slang%3D%22en-US%22%3EI%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1894907%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20search%20and%20return%20the%20data%20from%20two%20different%20sheets%20by%20using%20excel%20formulas%20such%20as%20xlookup%2C%20index%20%26amp%3B%20match%2C%20and%20so%20on.%3C%2FP%3E%3CP%3EWhat%20I%20want%20to%20do%20is%20that%20I%20want%20to%20find%20the%20PO%23%20value%20that%20has%20the%20correct%20date%20by%20using%20data%20from%20two%20different%20sheets.%3C%2FP%3E%3CP%3ESheet1%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screen%20Shot%202020-11-17%20at%2021.40.20.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F234116i86C1998D43134C4F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Screen%20Shot%202020-11-17%20at%2021.40.20.png%22%20alt%3D%22Screen%20Shot%202020-11-17%20at%2021.40.20.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20need%20to%20fill%20out%20yellow%20highlighted%20cells%20by%20using%20two%20different%20data%20from%20sheet2%20and%20sheet3.%3C%2FP%3E%3CP%3ESheet2%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screen%20Shot%202020-11-17%20at%2021.39.25.png%22%20style%3D%22width%3A%20365px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F234115iD501035065B866F6%2Fimage-dimensions%2F365x125%3Fv%3D1.0%22%20width%3D%22365%22%20height%3D%22125%22%20role%3D%22button%22%20title%3D%22Screen%20Shot%202020-11-17%20at%2021.39.25.png%22%20alt%3D%22Screen%20Shot%202020-11-17%20at%2021.39.25.png%22%20%2F%3E%3C%2FSPAN%3E%E2%80%83%3C%2FP%3E%3CP%3ESheet3%E2%80%83%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screen%20Shot%202020-11-17%20at%2021.40.51.png%22%20style%3D%22width%3A%20216px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F234117i1769B812B3B77FCE%2Fimage-dimensions%2F216x196%3Fv%3D1.0%22%20width%3D%22216%22%20height%3D%22196%22%20role%3D%22button%22%20title%3D%22Screen%20Shot%202020-11-17%20at%2021.40.51.png%22%20alt%3D%22Screen%20Shot%202020-11-17%20at%2021.40.51.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI'm%20having%20trouble%20because%20sheet%203%20does%20not%20provide%20the%20date%2C%20and%20sheet2%20is%20frequently%20modified.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20question%20is%20what%20function%20can%20I%20use%20to%20search%20and%20return%20the%20correct%20PO%23%20that%20has%20a%20correct%20date%3F%3C%2FP%3E%3CP%3Eor%20is%20there%20any%20other%20way%20such%20as%20python%20or%20VBA%20that%20I%20can%20solve%20this%20problem%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1894907%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1895457%22%20slang%3D%22en-US%22%3ERe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1895457%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871690%22%20target%3D%22_blank%22%3E%40Colinahn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20one%20is%20a%20bit%20tricky%20since%20Sheet3%20will%20be%20vulnerable%20to%20any%20sort%2Forder%20changes.%3C%2FP%3E%3CP%3EThe%20initial%20solution%20is%20to%20use%20INDEX%2FMATCH%20that%20uses%20multiple%20conditions%20and%20the%20qty%20as%20the%20Unique%20ID%20(UID)%20-%20not%20the%20best%20recommendation%20to%20go%20about%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECreating%20an%20array%20with%20multiple%20conditions%20that%20you%20can%20control%20the%20nth%20value%20of%20the%20result-%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DINDEX(%24D%244%3A%24D%247%2C%0AIF(COUNTIF(%24E12%3AE12%2CE12)%26gt%3B1%2C%0ASMALL(IF(%24E%244%3A%24E%247%3DE12%2C%0AIF(%24C%244%3A%24C%247%3D%24C%2412%2C%0AROW(%24C%244%3A%24C%247)-ROW(INDEX(%24C%244%3A%24C%247%2C1%2C1))%2B1))%2CCOUNTIF(%24E12%3AE12%2CE12))%2C%0ASMALL(IF(%24E%244%3A%24E%247%3DE12%2C%0AIF(%24C%244%3A%24C%247%3D%24C%2412%2C%0AROW(%24C%244%3A%24C%247)-ROW(INDEX(%24C%244%3A%24C%247%2C1%2C1))%2B1))%2CCOUNTIF(%24E12%3AE12%2CE12))))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22adversi_0-1605623858533.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F234131iB76E72C434CCB987%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22adversi_0-1605623858533.png%22%20alt%3D%22adversi_0-1605623858533.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20recommended%20route%20is%20to%20create%20a%20link%20PO%20and%20date%20in%20Sheet3%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1899065%22%20slang%3D%22en-US%22%3ERe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1899065%22%20slang%3D%22en-US%22%3EHi%2C%20Thanks%20for%20the%20reply.%3CBR%20%2F%3EI%20tried%20(literally%20copied%20and%20pasted)%20your%20formula%2C%20but%20it%20showed%20%23NUM%20error.%3CBR%20%2F%3EAny%20reason%20why%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1899474%22%20slang%3D%22en-US%22%3ERe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1899474%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871690%22%20target%3D%22_blank%22%3E%40Colinahn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20have%20to%20make%20sure%20the%20ranges%20are%20linking%20to%20the%20appropriate%20sheet%20and%20since%20these%20are%20arrays%2C%20press%20Ctrl%20%2B%20Shift%20%2B%20Enter%20to%20see%20the%20curly%20brackets%20%7B%20%7D%20surrounding%20the%20formula.%20If%20you%20continue%20to%20have%20issues%2C%20send%20over%20your%20file%20and%20I%20can%20help%20apply%20it%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1900795%22%20slang%3D%22en-US%22%3ERe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1900795%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F867265%22%20target%3D%22_blank%22%3E%40adversi%3C%2FA%3E%26nbsp%3BHi%20I%20uploaded%20a%20sample%20worksheet.%20I%20was%20able%20to%20return%20a%20value%20of%20cell%20C3%20by%20using%20your%20formula%2C%20but%20when%20I%20applied%20to%20other%20cell%2C%20it%20returned%20a%20wrong%20value%20(cell%20E3%20and%20C5).%20I'd%20be%20really%20appreciate%20if%20you%20could%20help%20finding%20what%20went%20wrong%20and%20fixing%20issues.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1901374%22%20slang%3D%22en-US%22%3ERe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1901374%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871690%22%20target%3D%22_blank%22%3E%40Colinahn%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehere%20you%20go%20-%20the%20issue%20was%20the%20Countif%20reference%2C%20it%20should%20have%20been%20the%20qty%20figure%20rather%20than%20the%20product%20code%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1906541%22%20slang%3D%22en-US%22%3EtRe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1906541%22%20slang%3D%22en-US%22%3E%3CP%3EIt%20works%20perfectly!%20Thank%20you%20so%20much%20for%20your%20help.%3CBR%20%2F%3EIf%20you%20don't%20mind%2C%20could%20you%20please%20tell%20me%20how%20this%20could%20work%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1907110%22%20slang%3D%22en-US%22%3ERe%3A%20tRe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1907110%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F871690%22%20target%3D%22_blank%22%3E%40Colinahn%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3EGlad%20to%20hear%20it!%20Here%20is%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.excelhow.net%2Fhow-to-find-nth-occurrence-with-multiple-criteria-using-indexmatch.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Esource%3C%2FA%3E%20I%20used.%3C%2FP%3E%3CP%3EThe%20idea%20is%20to%20the%20get%20nth%20Occurrence%20for%20a%20multiple%20criteria%20search.%20However%2C%20since%20there%20is%20no%20unique%20ID%20associated%2C%20the%20next%20best%20figure%20to%20use%20for%20a%20reference%20lookup%20is%20the%20qty%20figure.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20being%20the%20case%2C%20a%20COUNTIF%20function%20is%20used%20to%20check%20if%20the%20figure%20is%20occurring%20for%20the%20first%20time%20or%20has%20already%20been%20searched%20before%2C%20and%20that%20becomes%20the%20nth%20figure%20used%20for%20the%20search.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eie.%20cell%20C3%20and%20C5%20share%20a%20qty%20of%20100.%3C%2FP%3E%3CP%3EC3%20looks%20into%20the%20first%20row%20match%20that%20returns%20the%20correct%20PO.%3C%2FP%3E%3CP%3EC5%20accounts%20that%20qty%20%3D%20100%20is%20now%20the%20second%20occurrence%2C%20and%20returns%20the%20second%20row%20match.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20mentioned%20in%20the%20beginning%2C%20the%20pulls%20are%20susceptible%20to%20%3CSTRONG%3Esort%20changes%3C%2FSTRONG%3E%20in%20Tab%203.%20To%20solve%20this%2C%20there%20will%20need%20to%20be%20a%20connection%20between%20PO%20and%20date.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1917233%22%20slang%3D%22en-US%22%3ERe%3A%20tRe%3A%20I%20really%20need%20a%20help%20with%20finding%20%26amp%3B%20matching%20data%20from%20two%20different%20sheets.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1917233%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F867265%22%20target%3D%22_blank%22%3E%40adversi%3C%2FA%3E%26nbsp%3BThank%20you%20for%20the%20explanation.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20any%20way%20that%20I%20can%20make%20a%20connection%20between%20PO%20and%20date%3F%20or%20Qty%20and%20date%3F%3C%2FP%3E%3CP%3EWhat%20I%20tried%20was%20to%20link%20qty.%20to%20date%20on%20the%20sheet%20that%20has%20qty.%20and%20date%2C%20and%20then%20tried%20to%20make%20a%20connection%20again%20with%20that%20cell%20to%20PO.%20In%20this%20way%2C%20I%20thought%20it%20would%20flexibly%20change%20even%20the%20qty%20changes%20or%20in%20any%20modification.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20you%20suggested%20works%20great%2C%20but%20if%20there%20is%20an%20adjustment%20made%20in%20one%20sheet%2C%20PO%20also%20changes%20or%20it%20shows%20the%20wrong%20PO.%20For%20example%2C%20C3%20and%20C5%20shared%20the%20same%20qty%20let's%20say%20500%2C%20but%20a%20total%20qty%20of%20C3%20got%20split%20into%20200%20and%20300%20but%20shares%20the%20same%20PO%23.%20C3%20has%20two%20same%20PO%20and%20C5%20has%20a%20different%20PO.%20The%20problem%20is%20that%20the%20PO%20sheet%20does%20not%20get%20an%20update.%20Therefore%20the%20PO%20for%20C5%20shifts%20to%20C3%20(qty%20300).%20If%20I%20modify%20PO%20data%2C%20PO%23%20applies%20to%20the%20correct%20cell%2C%20but%20it%20takes%20time%20to%20adjust%20PO%20data%20every%20time%20when%20there%20is%20a%20change.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20advise%20if%20there%20is%20any%20way%20that%20I%20can%20make%20a%20connection%20between%20qty%20and%20date.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi,

 

I'm trying to search and return the data from two different sheets by using excel formulas such as xlookup, index & match, and so on.

What I want to do is that I want to find the PO# value that has the correct date by using data from two different sheets.

Sheet1

Screen Shot 2020-11-17 at 21.40.20.png

I need to fill out yellow highlighted cells by using two different data from sheet2 and sheet3.

Sheet2

Screen Shot 2020-11-17 at 21.39.25.png

Sheet3 

Screen Shot 2020-11-17 at 21.40.51.png

I'm having trouble because sheet 3 does not provide the date, and sheet2 is frequently modified.

 

My question is what function can I use to search and return the correct PO# that has a correct date?

or is there any other way such as python or VBA that I can solve this problem?

 

10 Replies
Highlighted

@Colinahn 

This one is a bit tricky since Sheet3 will be vulnerable to any sort/order changes.

The initial solution is to use INDEX/MATCH that uses multiple conditions and the qty as the Unique ID (UID) - not the best recommendation to go about it.

 

Creating an array with multiple conditions that you can control the nth value of the result-

 

=INDEX($D$4:$D$7,
IF(COUNTIF($E12:E12,E12)>1,
SMALL(IF($E$4:$E$7=E12,
IF($C$4:$C$7=$C$12,
ROW($C$4:$C$7)-ROW(INDEX($C$4:$C$7,1,1))+1)),COUNTIF($E12:E12,E12)),
SMALL(IF($E$4:$E$7=E12,
IF($C$4:$C$7=$C$12,
ROW($C$4:$C$7)-ROW(INDEX($C$4:$C$7,1,1))+1)),COUNTIF($E12:E12,E12))))

 

 

adversi_0-1605624439367.png

 

The recommended route is to create a link PO and date in Sheet3

 

Highlighted
Hi, Thanks for the reply.
I tried (literally copied and pasted) your formula, but it showed #NUM error.
Any reason why?

Highlighted

@Colinahn 

You have to make sure the ranges are linking to the appropriate sheet and since these are arrays, press Ctrl + Shift + Enter to see the curly brackets { } surrounding the formula. If you continue to have issues, send over your file and I can help apply it

Highlighted

@adversi Hi I uploaded a sample worksheet. I was able to return a value of cell C3 by using your formula, but when I applied to other cell, it returned a wrong value (cell E3 and C5). I'd be really appreciate if you could help finding what went wrong and fixing issues.

Highlighted
Best Response confirmed by Colinahn (Occasional Contributor)
Solution

@Colinahn 

here you go - the issue was the Countif reference, it should have been the qty figure rather than the product code 

Highlighted

It works perfectly! Thank you so much for your help.
If you don't mind, could you please tell me how this could work?

 

Highlighted

@Colinahn 
Glad to hear it! Here is the source I used.

The idea is to the get nth Occurrence for a multiple criteria search. However, since there is no unique ID associated, the next best figure to use for a reference lookup is the qty figure.

 

That being the case, a COUNTIF function is used to check if the figure is occurring for the first time or has already been searched before, and that becomes the nth figure used for the search.

 

ie. cell C3 and C5 share a qty of 100.

C3 looks into the first row match that returns the correct PO.

C5 accounts that qty = 100 is now the second occurrence, and returns the second row match.

 

As mentioned in the beginning, the pulls are susceptible to sort changes in Tab 3. To solve this, there will need to be a connection between PO and date.

Highlighted

@adversi Thank you for the explanation.

 

Is there any way that I can make a connection between PO and date? or Qty and date?

What I tried was to link qty. to date on the sheet that has qty. and date, and then tried to make a connection again with that cell to PO. In this way, I thought it would flexibly change even the qty changes or in any modification.

 

What you suggested works great, but if there is an adjustment made in one sheet, PO also changes or it shows the wrong PO. For example, C3 and C5 shared the same qty let's say 500, but a total qty of C3 got split into 200 and 300 but shares the same PO#. C3 has two same PO and C5 has a different PO. The problem is that the PO sheet does not get an update. Therefore the PO for C5 shifts to C3 (qty 300). If I modify PO data, PO# applies to the correct cell, but it takes time to adjust PO data every time when there is a change.

 

Please advise if there is any way that I can make a connection between qty and date.

Highlighted

@Colinahn 

The solution will vary based on how the data architecture is set up. For example, if Tab 2 and Tab 3 were downloaded tables or manually created. This is how the tabs are currently connected:

adversi_1-1605880560153.png

 

My main question is: Did you create Tab 2 or was it provided? 

 

I would see the end goal to have a table like Tab 3 but with one more column of data to make it easier to work with and complete the connection. This will eliminate the duplicate Tab 2 table and make any changes or updates to the data more manageable and reliable:

 

adversi_0-1605880510914.png

 

From there the formula will change to something much more simpler.

Highlighted

@adversi 

Tab2 was provided and what I need to do is fill out the row on the Tab2 column.

I agree that it'd be much easier if the date was provided. But since no date is provided, I have to find another way to make it work.