How to pair 2 columns together in Excel? - excel

For example, One table is the formula, and the other is the data sheet.
For the formula, I want Column A to pair to Column B.
So, ZIPCODE1 in A1 equates to $6 in B1.
Like
12345 - $5
54312 - $4
12422 - $7
So, in the data sheet, whenever I type a zipcode, it will autofill/calculate with that dollar amount.

Sounds like you may be after a lookup formula.
You need to have a table like the above in your workbook, for reference. Let's say that this table is in Sheet2, from cell A1 to B4. Make row 1 the labels, ZipCode and Fee, so everybody can easily recognize what data the columns hold.
Let's further assume that in Sheet1 of your workbook you have a zip code in cell A1 and you want to see the respective price in cell B1. You now can use this formula in cell B1
=vlookup(A1,Sheet2!$A$1:$B$100,2,False)
In words: find the value from A1 (of the current sheet) in the first column of the table in Sheet2 that starts in A1 and goes to B100 (I'm using row 100 as an arbitrary last row of the table. There are more advanced ways to make the table reference dynamic). Return the value in the second column where column A has an exact match. For more info use the Excel help for Vlookup.
Another option is an Index/Match combo
=Index(Sheet2:$B:$B,match(A1,Sheet2!$A:$A,0))
In words: look at column B in sheet 2 and return the cell where column A in Sheet2 has an exact match for my value in A1 (in the current sheet).

Related

Reference data from a range on one sheet to individual cells on another based on neighboring cell value (Excel 365)

Sheet 1 will be references to individuals based on unique identifiers, such that column A will be their name and column B will have the identifier.
Sheet 2 will be an imported list of all individuals in our data set, such that column A is their name and column B is the identifier.
The goal is to be able to fill cells in Sheet 1 Column A based off of values entered in Sheet 1 Column B, by referring to Sheet 2 Column B., i.e. if the column B values match between sheets, I want the neighboring value in Column A to be copied over.
I'm a novice at this, but I don't think CONCATENATE is what I'm looking for, so the closest I've gotten is:
=IF($B:$B=Sheet2!$B:$B,Sheet2!$A:$A)
which results in a SPILL error, because I think my formula is trying to display multiple reference cells of data in one destination cell, whereas a formula such as
=IF(B3=Sheet2!B3, Sheet2!A3)
returns expected results, but is too limited for my purposes, in that it would be potentially faster to just manually enter the data, at that rate.
Trying to simplify, I'll have a sheet that has say 100 people in it, with identifiers 1 through 100. If I punch in their identifier in a separate sheet, I'm looking for their name to be displayed in a neighboring cell, or at least to have their name returned in the same cell, i.e. I enter "90" in Sheet1A1 or Sheet1B1 and it gives me "John Doe" in A1, which is the value of Sheet2B90 that's associated with the number "90" that is in Sheet2A90.
So VLOOKUP does work with some wrangling, but XLOOKUP was the ultimate solution to what I needed. A formula such as
=XLOOKUP(A13,$A$1:$A$10,$B$1:$C$10,NONE)
Would return data from B1 through B10 and C1 through C10 to elsewhere in the sheet, in this case next to a lookup cell A13 into cells B13 and C13, if the value in A13 appears within the lookup array of A1 through A10. Locking the cells with $ allows the formula to be dragged down a range of lookup cells without Excel incrementing the values of the lookup or return arrays, just the value of the lookup cell.

Using VLOOKUP to match 2 cells sheet2 to sheet1 and return the 3rd cell

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)

SUM with INDEX and MATCH

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.

Cumulative Amounts of Dupe-only Items in a Resultant Sheet

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.

Formula to deliver answer that is in another sheet, to the left of a matched cell

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.

Resources