I have 2 worksheets that are connected through a unique ID column shared by the two sheets. I made the two below spreadsheets to test the formula as my actual data is quite long.
I am using the INDEX and MATCH formulas to pull a value from Sheet2 to populate a cell in Sheet1 if the ID value found in the row of Sheet1 matches an ID value found in Sheet2. I can accomplish this with the following formula
=INDEX(Sheet2!B:B,MATCH(Sheet1!A:A,Sheet2!A:A,0))
However, what I am actually after is for the INDEX to SUM of all values in the WGT column on Sheet2 on Sheet1 when there is a MATCH between the two ID columns (I know with this test data there are two instances of every ID on Sheet2). The above formula only INDEXes the first WGT value when a MATCH is found between the ID columns.
I am pretty sure I am supposed to use some variation of the SUMIF formula but I can't seem to get one that works at all. Thanks for any help!
The syntax for Sumif is Sumif(criteria range, criterion, [sum range]). So, you would need in Sheet2, cell B2
=sumif(Sheet1!A:A,Sheet2!A2,Sheet1!B:B)
In words: generate a sum or all numbers in column B of Sheet1, where column A of Sheet1 equals the value of cell A2 on Sheet2.
Copy that down.
Alternatively, you could click in the data of Sheet1 and insert a pivot table. Drag the ID field into the Rows area and the WGT field into the Values. Just a few clicks, no formula.
Another option to use Sum + Index function
In sheet1, B2 array formula copied down :
=SUM(INDEX(Sheet2!B:B,N(IF(1,(Sheet2!A:A=A2)*ROW(Sheet2!A:A)))))
This is an array formula and needs to be confirmed by pressing with Ctl + Shift + Enter.
Related
Intended behaviour
Where two values in the same row of two different columns MATCH two values in the same row of two different columns in another sheet, the data in the same row of the third column of the additional sheet is displayed in a third column of the original sheet.
For example...
Where Sheet1 A2 ("1") AND B2 ("A") MATCH Sheet2 A5 ("1) AND B5 ("A"), the value in Sheet2 D5 (1500%) should be displayed in C2 of Sheet1
I have read the below similar questions:
Match two columns in table to two columns in separate table and return value &
Match values in two columns and return value using vlookup from third column in Excel
and tried working them into my spreadsheet but the data I get back is either a "" (blank), "#VALUE" or "#NA"
The below formula seems to be the closest potential resolution but sadly it's spitting out blank from what seems to be an error 🤔
I have also tried the below formula with CSE (Ctrl +Shift + Enter) but nothing 😕
=IFERROR(INDEX(Sheet2!D2:D7, MATCH(Sheet1!A2:A7,Sheet2!A2:A7,0),MATCH(Sheet1!B2:B7,Sheet2!B2:B7,0)),)
Any assistance would be appreciated for this excel noob, thank you :)
You can try this in your Sheet1!C2:
=INDEX(Sheet2!$D$2:$D$7,MATCH(1,(Sheet2!$A$2:$A$7=Sheet1!A2)*(Sheet2!$B$2:$B$7=Sheet1!B2),0))
I have been using VLOOKUP() to populate worksheets with Inventories, however I'm stuck with an issue where one column has the same value in multiple cells, I need to match 2 cells from sheet 2 with sheet 1 and have it return the 3rd cell from sheet 1 into sheet 2.
I'm working with about 350 rows in both sheets, and in some cells the same/different values repeat it self hence needing it to match with 2 cells in the same row.
This is the formula I currently use:
=VLOOKUP(A1&L1,'Sheet1'!$A$1:$E$351,3,FALSE)
I'm expecting it to return the value that's in the 3rd column on sheet 1 in the row that matched the values of Cell A1 and L1 in sheet 2. and the same going on A2 & L2 then A3 & L3 and so forth.
Unless you have values in Column A of your 'Sheet1' that are the equal to to concatenation of your values in Columns A and L in 'Sheet2', the formula will not work.
Instead, I'd try FILTER if you have the newest version of Excel. Something like:
=FILTER('Sheet1'!$C$1:$C$351,
(('Sheet1'!$A$1:$A$351=A1)*('Sheet1'!$L$1:$L$351=L1)))
Another option is INDEX. Something like:
=INDEX('Sheet1'!$C$1:$C$351,
MATCH(A1&L1, 'Sheet1'!$A$1:$A$351&'Sheet1'!$L$1:$L$351,0),
3)
The only way to do this task is to use a helper column
Go to Sheet one where the data table is, insert a column at the starting point of data e.g your Data set starting in SHEET1 from the column A. so insert new column in A
use this formula in A1
=CONCATENATE(B1,C1,D1,E1,F1) Press Enter, Drag the formula down to A351
now go to sheet2 and use this formula in the result cell
=VLOOKUP(A1&L1,'Sheet1'!$A$1:$F$351,4,0)
Sheet 1 goes like this:
Sheet 2 should be like this:
ITEMS QUANTITIES
APPLE 4
GUAVA 2
Sorry for writing the spreadsheet in here, as I'm not allowed to include more than 1 image yet.
Suppose you have the following named ranges:
ITEMS being the data in ITEMS column on your Sheet1;
QUANTITY being the data in QUANTITY column on your Sheet1.
Enter the following formula in Cell D2 on your Sheet2:
=IFERROR(INDEX(ITEMS,MATCH(0,COUNTIF($D$1:D1,ITEMS),0)),"")
Please note it is an array formula which requires you to press Ctrl+Shift+Enter upon finishing the formula in the formula bar.
Drag it down until there is no more items showing up.
Then you can enter the following formula in Cell E2 on your Sheet2 and drag it down:
=SUMIF(ITEMS,D2,QUANTITY)
As you can see from the above screenshot, there may be some empty cells in Column D as I used IFERROR to return blank cells if there is no more distinct item. The corresponding quantity will be 0 consequently. You can choose to delete them or hide them on your worksheet.
By the way I am not sure why Pivot Table is out of the picture as it is actually a faster and easier approach than formula and you do not have to worry about the blank cells returned by the formula if the number of unique items is uncertain. All you need to do is to highlight the source data, insert a pivot table, and put the ITEM in Rows and QUANTITY in Values field.
EDIT: Update to also extract unique distinct values:
Enter this formula in cell A2 of Sheet2:
=IFERROR(LOOKUP(2,1/(COUNTIF($A$1:A1,Sheet1!$A$2:$A$300)=0),Sheet1!$A$2:$A$300), "")
Change 300 to the actual last row of your data and copy that formula down until it returns empty cells.
Then just use a regular SUMIF in cell B2 of Sheet2:
=SUMIF(Sheet1!A2:A300, A2, Sheet1!B2:B10)
Then, type whatever fruit you're looking for incell A2 of Sheet2. Continue like this in the following rows for all the fruits you need.
I'm trying to get a value from a table in another sheet based on two values in the current sheet.
This is what I have in the first sheet
And this is what I have in the second sheet
At the moment I get the expected indicador from sheet 2 for A1 cell (can be P01, P02, P03,...). But I want it to search based the cells A1 and B3, because B3 can assume equal values to different A1 values (P01, P02, P03,...).
Is it possible to select more than one value on =VLOOKUP (value, table, col_index, [range_lookup]) ?
You can look into using a combination of INDEX and MATCH:
Formula in F3:
=INDEX(A2:A3,MATCH(1,INDEX((B2:B3=F1)*(C2:C3=F2),),0))
If you were looking to return the value 11 with the other two parameters, you can adapt this to a formula in F2:
=INDEX(A2:A3,MATCH(1,INDEX((A2:A3=F3)*(B2:B3=F1),),0))
You can obviously adapt this to your needs...
I am working on a formula that delivers text from a cell in another sheet, that is to the left of a matched cell. This is as far as I have got.
=LOOKUP(A2,Sheet1!$A$1:$A$46729,Sheet1!$B$2:$B$46729)
In sheet 1 there is a selection of product data. There are product numbers in column A and there needs to be the correct barcode placed in each cell in column B. In sheet 2 there are also product codes in column A and barcodes in column B. However there are significantly more rows of data in Sheet 2.
What is needed is a formula to place in Sheet1!B2 that looks up Sheet1!A2 in Sheet2!A2:A50000. If A2 is matched at e.g. Sheet2!A90, then the result in Sheet1!B2 should be the value in Sheet2!B90. The specific issue I am having is getting the Sheet2!B90 in Sheet1!B2.
You can use Index/Match:
=Index(Sheet2!$B$2:$B$46729,Match(A2,Sheet2!$A$2:$A$46729,0))
Or VLOOKUP:
=VLOOKUP(A2,Sheet2!$A$2:$B$46729,2,false)
The last parameters of the MATCH and VLOOKUP functions respectively are very important as it forces it to search for an exact value and not assume a sorted list. VLOOKUP would no longer work if you reversed columns A and B on Sheet2 because the lookup column has to be the first column in the lookup range.