Formula for inserting value from Sheet 1 if word matches in Sheet 2 - excel

I have two sheets in excel.
Sheet1 has 4 columns with following pattern.
ID Name 1 Name 2 Name 3
AAA1 Ant P.Ant Ant IgE
AAA2 Peanut Peanut.IgE Peanut.IgE Serum
AAA3 Tomato
AAA4 Apple Apple.IgE
Sheet 2 has following two columns:
Name ID
Ant AAA1
Grass #NA#
Apple.IgE AAA4
Tomato AA3
Mango #NA#
I would like to check whether whole text in column A (sheet 2) exist in any of columns between B to D in sheet 1.
If yes, display ID mentioned in column A (from sheet 1) against particular row in Sheet 2.

A bit long-winded (and doesn't tally with your result for 'Tomato') but please try in Sheet2 B2 and copied down to suit:
=IFERROR(IFERROR(INDEX(Sheet1!A:A,MATCH(A2,Sheet1!B:B,0)),INDEX(Sheet1!A:A,MATCH(A2,Sheet1!C:C,0))),INDEX(Sheet1!A:A,MATCH(A2,Sheet1!D:D,0)))

Related

Stacking two list of data on top of each other in excel

I have two excel sheets with one column each.
Sheet1
A
Fruits
Orange
Apple
Grapes
Sheet2
B
Vegetables
Tomatoes
Potatoes
Now, how do I use excel formula and populate on a third sheet stacking just the values
A
Orange
Apple
Grapes
Tomatoes
Potatoes
If your data has a header in Sheet1!A1 and Sheet2!A1 then in Sheet3!A1 you could use (and drag down):
=IF(ROW()<=ROWS(Sheet1!$A$2:$A$4),
Sheet1!A2,
SUBSTITUTE(
INDEX(Sheet2!A:A,
ROW()-ROWS(Sheet1!$A$2:$A$4)+1),
"",""))
If the row number in the new sheet is smaller than or equal to the count of rows in the range of Sheet1 then the result is Sheet1!A2:A4 if the row is greater it'll index Sheet2 column A and will get the result for in that range with the row that equals to the current row number minus the total count of rows of Sheet1!A2:A4 + 1 to take the header into account.
In Office 365 a simple =HSTACK(Sheet1!A2:A4,Sheet2!A2:A3) would do.

text matching with logical function?

Please help me to formulate the following formula:
Actually I am trying to make a costing sheet for recipes.. I am listing all the items in sheet 1 and on sheet 2 all recipes with their quantities of items..
sheet 1
A B
1 item price/gm
2 chicken 10
Sheet 2
A B C
1 item Qty (in gm) cost
2 chicken 150 formula?
now in sheet 2 C2 I need a formula that matches sheet2 A2 with sheet1 column A and then multiply sheet2 B2 with sheet1 B2.. and this will same for all the items in sheet2.. if I put any item in sheet2 it looks up in sheet1 and then multiply the price with qty in sheet2..
Use VLOOKUP:
=B2*VLOOKUP(A1,'Sheet 1'!A:B,2,false)

INDEX MATCH obtaining values for duplicate names

I have one example table with the following data in Sheet1 with the following random data
------A ----------------- B ----------------------C ------------------------D
1 --First--------------Last-----------------Start Date--------------End Date
2 --John--------------Smith--------------08/08/2014------------01/01/2015
3---John--------------Smith--------------08/11/2014------------17/11/2014
4---John--------------Smith--------------06/06/2014------------23/12/2014
5---Abel--------------Jones--------------14/05/2014------------29/04/2015
6---Abel--------------Jones--------------04/07/2014------------26/04/2015
Then I have another table in Sheet2
------A ----------------- B ----------------------C ------------------------D
1 --First--------------Last-----------------Start Date--------------End Date
2 --John--------------Smith---------------------------------------------------
3---John--------------Smith---------------------------------------------------
4---John--------------Smith---------------------------------------------------
5---Abel--------------Jones---------------------------------------------------
6---Abel--------------Jones---------------------------------------------------
I am using INDEX MATCH to transfer the data between the two sheets.
=INDEX(Sheet1!$C:$C,
MATCH(1,INDEX((Sheet1!$A:$A=$A3)*(Sheet1!$B:$B=$B3),0),0))
To populate column C with the start dates from Sheet1.
=INDEX(Sheet1!$D:$D,
MATCH(1,INDEX((Sheet1!$A:$A=$A3)*(Sheet1!$B:$B=$B3),0),0))
and this to populate column D with the end dates.
The problem is, when I perform this INDEX MATCH function, for a duplicate name, it will only copy over the first value. So this formula will paste 08/08/2014 into all 'John Smith' Start dates in column C of Sheet2.
How do I obtain all values so that C2 should be 08/08/2014, C3 should be 08/11/2014, C4 should be 06/06/2014 etc.
One solution would be to insert a column in both sheets with a "running count" of instances of the same name. For example, insert col C and in C2 enter =IF(A2&B2 = A1&B1, C1+1, 1). This starts the count at 1 if the concatenated first and last name is new, and increases the previous count by 1 if not. So you would have
First Last Count by Person
John Smith 1
John Smith 2
John Smith 3
Abel Jones 1
Abel Jones 2
George Washington 1
Thomas Jefferson 1
Thomas Jefferson 2
You can then add this column to your MATCH() function (and change the lookup column as necessary).
Edit: It is worth noting that this requires your raw data is sorted by name.
You can narrow the $A:$A refferances to something like $Ax+1:$Ay where y = last row of your excel sheet and x is position of previous occurance of this name/surname (you could store this in some dummy column).

Need to match data in different sheets and replace data in another cell if it's a match

I need to match data in column A2 and so on in sheet 1 to data in column A2 and so on in sheet 2. If the data in column A of sheet 1 and sheet 2 match I need the data in column B & C of sheet 2 to replace data in column B & C of sheet 1. I know VERY little about doing this kind of stuff so any help would be GREATLY appreciated!
SHEET 1
A B C
2 12345 5.35 9.95
3 15874 4.22 10.99
4 11111 2.24 5.99
5 98745 5.33 9.95
6 88552 4.24 8.95
SHEET 2
A B C
2 11111 2.09 5.79
3 12345 5.11 9.89
4 88552 4.01 8.79
NEED SHEET 1 to change to
A B C
2 12345 5.11 9.89
3 15874 4.22 10.99
4 11111 2.09 5.79
5 98745 5.33 9.95
6 88552 4.01 8.79
On a third sheet use these functions
column a ='sheet1'!a2
column b =if('sheet1'!b2='sheet2'!b2,'sheet2'!b2,'sheet1'!b2)
column c =if('sheet1'!c2='sheet2'!c2,'sheet2'!c2,'sheet1'!c2)
Copy sheet3 and paste the values into sheet1.
This should work unless column a does match. or if you need to do this dynamically. If column a doesn't match some vlookups can be thrown in.
I your data does match in column a your formulas could look something like this.
column a ='sheet1'!a2
column b =if(not(iserror(vlookup(a2,'sheet2'!a:c,2,false))),vlookup(a2,'sheet2'!a:c,2,false),vlookup(a2,'sheet1'!a:c,2,false))
column c =if(not(iserror(vlookup(a2,'sheet2'!a:c,3,false))),vlookup(a2,'sheet2'!a:c,3,false),vlookup(a2,'sheet1'!a:c,3,false))
this is too much to put in a comment so I'm putting it in answer.
The way I under stand is, since sheet1 has more data, you only want to be doing this comparison when sheet1 and 2 both have data on the row. so If sheet1 has data in rows 1 - 100, and sheet2 has data in rows 1 to 50, you only want to be doing this comparison for the first 50 rows in sheet1 right?
So, rather than copying and pasting formulas, what you can do is, in sheet1, find an unused column. go to the first row. in the formula box, type: "=if(" without the quotes. now, select the first cell to compare, according to your example you'd select sheet1, A2. then type "=" without quotes. then select the second cell you want to compare - in your example, sheet2, A2. then type "," without quotes. then select the cell from which you want the data if the first 2 cells are equal. in your example, sheet2 B2. then type "," without quotes, then select the cell with the data to use if the first 2 cells are not equal. in your example, sheet1 b2. then type ")" without the quotes.
so using your example, the function would look similar to how bigtree had it: =if('sheet1'!A2='sheet2'!A2,'sheet2'!b2,'sheet1'!b2)
so, this will compare sheet1 cell A2 with sheet2 A2 and if they are equal, the cell you put the formula in will the have the value of sheet2 b2, and if they are not equal, the cell with this formula will have the value of sheet1 B2. then, drag this formula down for however many rows you want, and the formula will adjust automatically for each row. you'll see the numbers increase. then, select the column with the formulas, right click and select copy, then right click and go to paste special, and click values. this will make it so the column contains only the values, not the formulas, now you can paste this data in column B sheet 1.
you can reuse this formula for whatever columns, just follow the steps.
HTH, good luck!

How to compare 2 cells to another 2 cells in a different sheet in excel?

I want to know how to compare or know the difference of 2 cells to another 2 cells in a different sheet in excel 2007
Example:
Sheet 1
A B
1 101 KIWI
2 102 APPLE
3 103 BANANA
Sheet 2
A B
1 101 KIWI
2 102 APPLE
3 103 ORANGE
I want to show the there is a difference in 3rd row on Sheet 1 and 2
Thanks
If you put =A1&B1 in C1 of each sheet and copy down then it is like comparing single columns. So with, in D1:
in Sheet1: =MATCH(C1,Sheet2!C:C,0)
in Sheet2: =MATCH(C1,Sheet1!C:C,0)
copied down in each case the resulting numbers should show the row number where the match is on the 'other sheet' (the lists need not be sorted) and otherwise #N/A for where matches have not been found.
There is obviously no need for the concatenation for the example provided, since the two 'A' columns are identical, but I take it that was because the example was simplified.

Resources