Search and return multiple values

craigfer

New Member
Joined
May 16, 2012
Messages
29
Office Version
  1. 365
We have data sets on three seperate sheets within Excel

We have a ORDER STATUS (Sheet named STATUS). The STATUS sheet contains all the order numbers as unique values.
ORDER NUMBERSTATUSAREACOMMENTS
100103637​
WSCHUNDER PREPARATIONINVESTIGATE
100000483​
WSCHUNDER PREPARATIONSEND
100180611​
SCHUNDER PREPARATIONSEND
100226506​
WSCHUNDER PREPARATIONINVESTIGATE

Order Numbers (Sheet named ON) which can contain one or more ITEM
ORDER NUMBERITEM
10000157511133628
10000984940006676
10000984940006833
10001833011170308
10001833040006398
10001885540013378
10001885511033495
10002076340002159
10002076340002160
10002076340002161
10002076340002162


We have a list of STOCK (Sheet name STOCK)
ITEMDESCSTOCK
40002159​
SEAL
17​
40002160​
ORING
0​
40002161​
ORING
37​
40002162​
ORING
16​
11170308​
GLOBE
0​
40006398​
GSKT
379​
40013378​
GSKT
25​
11033495​
PIPE CLAMP
4​

I want to be able to PASTE the orders number from STATUS in a new Sheet and produce headings like this. I also want the formula to return multiple values if the ORDER NUMBER has more than one material.
For the work to be completed we need stock of all the ITEM. Anything with a 0 value means we cannot complete the work for that ORDER NUMBER.
In the example below 40002160 has 0 stock so we cannot complete.
PASTE ORDER NUMBER *Paste in CELL A2*STATUSAREACOMMENTITEMDESCSTOCKCAN COMPLETE ORDER
100020763​
WSCHUNDER PREPARATIONINVESTIGATE
40002159​
SEAL
17​
NO
100020763​
WSCHUNDER PREPARATIONINVESTIGATE
40002160​
ORING
0​
NO
100020763​
WSCHUNDER PREPARATIONINVESTIGATE
40002161​
ORING
37​
NO
100020763​
WSCHUNDER PREPARATIONINVESTIGATE
40002162​
ORING
16​
NO

If STOCK is greater than 0 then it should return YES
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Please use XL2BB when posting data.
Anyway, you want to start with turning your data into Excel Tables like this:
Table Name: Status:
Book1
ABCD
1ORDER NUMBERSTATUSAREACOMMENTS
2100103637WSCHUNDER PREPARATIONINVESTIGATE
3100000483WSCHUNDER PREPARATIONSEND
4100180611SCHUNDER PREPARATIONSEND
5100226506WSCHUNDER PREPARATIONINVESTIGATE
STATUS

Table Name: OrderNumber:
Book1
AB
1ORDER NUMBERITEM
210000157511133628
310000984940006676
410000984940006833
510001833011170308
610001833040006398
710001885540013378
810001885511033495
910002076340002159
1010002076340002160
1110002076340002161
1210002076340002162
1310010363740002163
ON

Table Name: Stock:
Book1
ABC
1ITEMDESCSTOCK
240002159SEAL17
340002160ORING0
440002161ORING37
540002162ORING16
611170308GLOBE0
740006398GSKT379
840013378GSKT25
911033495PIPE CLAMP4
1040002163Plgr100
STOCK

And Table Name Report:
Book1
ABCDEFGH
1Order NumberStatusAreaCommentItemDescStockCan Complete Order?
2100103637WSCHUNDER PREPARATIONINVESTIGATE40002163Plgr100Yes
3100000483WSCHUNDER PREPARATIONSENDNot Found  NO
4100180611SCHUNDER PREPARATIONSENDNot Found  NO
5100226506WSCHUNDER PREPARATIONINVESTIGATENot Found  NO
Report
Cell Formulas
RangeFormula
B2:B5B2=IF([@[Order Number]]<>"",XLOOKUP([@[Order Number]],Status[ORDER NUMBER],Status[STATUS],"Not Found"),"")
C2:C5C2=IF([@[Order Number]]<>"",XLOOKUP([@[Order Number]],Status[ORDER NUMBER],Status[AREA],"Not Found"),"")
D2:D5D2=IF([@[Order Number]]<>"",XLOOKUP([@[Order Number]],Status[ORDER NUMBER],Status[COMMENTS],"Not Found"),"")
E2:E5E2=IF([@[Order Number]]<>"",XLOOKUP([@[Order Number]],OrderNumber[ORDER NUMBER],OrderNumber[ITEM],"Not Found"),"")
F2:F5F2=IF(ISNUMBER([@Item]),XLOOKUP([@Item],Stock[ITEM],Stock[DESC],"Not Found"),"")
G2:G5G2=IF(ISNUMBER([@Item]),XLOOKUP([@Item],Stock[ITEM],Stock[STOCK],"Not Found"),"")
H2:H5H2=IFS(AND(ISNUMBER([@Stock]),[@Stock]>0),"Yes",AND(ISNUMBER([@Stock]),[@Stock]<=0),"NO",[@Item]="Not Found","NO",TRUE,"")

It is VERY IMPORTANT that the numbers entered are actually numbers and not text. Note that the data in all the Order Number and Item columns is RIGHT JUSTIFIED. That is not formatting, that is how Excel displays numeric data including dates and times. If they were text as it LOOKS like they are in your ON table they would be LEFT JUSTIFIED without any formatting. Just to complete that thought, Errors and other special values like TRUE and FALSE are centered by Excel.
While it is not important whether or not the first three tables are Excel Tables, the Report table MUST be an official Excel Table. Note that if you copy the tables above, you will have to turn them into tables manually and name them appropriately for the Report table to work. I have added Paste and Match Destination Formatting to my QAT which makes pasting XL2BB data much cleaner. Aside from the formatting which you don't want in this case, for some reason it pastes everything to Wrap which is annoying. That paste option is not available when you copy XL2BB data.
As you'll find once you get that all set up, no "template" is needed. The Report table will add new rows and copy the formulas when a new row is added - which will happen when you enter data into the next table row in column A or have your cursor in the last row of column H and hit [Tab].
And BTW, NONE of the Order Numbers in the Status Table are in the ON table you posted. I had to add that one entry to see the formulas work. Items in the OrderNumber and Stock tables that I added manually are in Bold Red and why all the items are "Not found" except the item I added manually in the report.
And the Table Names are in Upper/Lower case because it makes them easier to read and I don't like Excel to YELL AT ME! (LOL)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top