Excel formula for: If match then paste - excel

I'm looking for a formula on excel to do the following.
If a value on a spreadsheet is a match to a value on another spreadsheet:
Then paste the cell next to the match from the first spreadsheet
into the cell next to the match on the other spreadsheet.
This is for a stock spreadsheet from my supplier, it is 2 columns, 1 with an item code and the 2nd with a quantity in stock.
I need to check if the code exists on my other spreadsheet and if so paste the stock quantity from the shop spreadsheet in the cell next to the match on my spreadsheet.

The LOOKUP and VLOOKUP functions seem to be what you need here.
Simply comparing one cell to another as other answers indicate will require both data sets to be in the same order and without gaps. LOOKUP and VLOOKUP remove this restriction.

Assume two worksheets W1 and W2. W1 and W2 both have columns A. You want to check, for example A1 on W1. If it matches A1 on W2, then you paste A1 from W1 to B1 on W2. Put this code in B1 on W2:
=IF(W1!A1=W2!A1,W1!A1,"")

Related

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)

Excel VLOOKUP using 2 colums from a table array

I have the below VLOOKUP formula
=IFERROR(VLOOKUP(#B5:B64,dbVEH!$A$2:$E$296,5,FALSE),"")
I am trying to create a formula that searches 2 columns on the table array. I have the range A$2:$E$296 however it only matches the A column and delivers the result from the E column.
I am trying to create a formula so that if Cell B5 on my main sheet = anything in column A OR anything in column B on the "dbVEH" sheet then display the result from the 5th E column on "dbVEH" in cell B5 on my main sheet.
My reasoning behind this is that I'm trying to cover alternative spellings inputted into B5:B64 on my main sheet. One cell could have "Thomas" and another cell could have "Tomas" but they both need to equal the same result. My table on sheet dbVEH has the first column "Thomas" and the second column "Tomas" to cover the different spelling types.
VLOOKUP will not do that. Use FILTER:
=#FILTER(dbVEH!$E$2:$E$296,(B5=dbVEH!$A$2:$A$296)+(B5=dbVEH!$B$2:$B$296))

Refer the same cell after applying filter in Excel

I have the following situation:
Sheet1
and Sheet2
In sheet 2 cell B1 is equals to Sheet1!B2 and it does not changes when I apply the filter in sheet one. Is there a way to set the filter on first sheet on the "C" and let the cell on the second sheet show 156566?
Can you put a helper column in Sheet1?
If so, add this a formula to Sheet!C1
=ROW()
and copy down for all data rows. Hide this column if you wish
Now, Formula for Sheet2!B1 is
=INDEX(Sheet1!$B:$B,AGGREGATE(15,5,Sheet1!$C:$C,2))
Filtering only hides the row, so Row2 is still technically "154221".
I found this solution using formulas to return the first visible cell in a row:
Find Value of First Visible Cell
Change your formula on Sheet 2 to the following and then hit Ctrl+Shift+Enter to apply the formula as an array:
=INDEX(Sheet1!B2:B5,MIN(IF(SUBTOTAL(3,OFFSET(Sheet1!B2,ROW(Sheet1!B2:B5)-ROW(Sheet1!B2),0)),ROW(Sheet1!B2:B5)-ROW(Sheet1!B2)+1)))
Note this will give the first visible cell on Sheet1 within the range of B2:B5. If you add more rows, you will need to update the range. There may be a more elegant way to handle that.

Cleaning a column from one sheet into another

Sorry if the title is off, but I have no way of making this short.
I have an excel file with 2 sheets: Sheet1 has the first column filled with data, but in a random pattern (ex: 6 consecutive cells are with data, 6 are without, other of the following alternate; basically there is no way of knowing if the next cell has data or not). I want to copy the first column from Sheet1 into Sheet2 without any blank cells or duplicate ones (the order of the data can be maintained or be changed as the result of the formula).
Can this be done without any coding?
Assuming your Sheet1 is as follows
Then in Cell A2 of Sheet2 enter the following formula
=IFERROR(INDEX(Sheet1!A$2:A$50,SMALL(INDEX(NOT(ISBLANK(Sheet1!$A$2:$A$50))*ROW($A$1:$A$49),0),COUNTBLANK(Sheet1!$A$2:$A$50)+ROW($A1))),"")
Drag/Copy down as required. Change range in formula as needed. See image for reference.
EDIT :
To get unique values from Column A of Sheet2 enter below formula in Cell B2 of Sheet2
=IFERROR(INDEX($A$2:$A$20,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$20),0,0),0)),"")

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