How to fill cells from sheet A with values from sheet B when ID matches (in Excel)? - excel

Consider the following 2 sheets. Sheet AAA has a list of companies with an emptry column ROA. Sheet BBB has a ROA value for some of these companies.
Sheet AAA
A B
1 ID ROA
2 1
3 2
4 3
5 4
Sheet BBB
A B
1 ID ROA
2 1 60.40
3 3 10.10
4 4 9.00
Looking at the ID in both sheets, I need a formula to fill in column AAA.B, resulting in
A B
1 ID ROA
2 1 60.40
3 2
4 3 10.10
5 4 9.00
What formula do I need in cell AAA.B2 (and down) to get this done? I believe VLOOKUP is the function appropriate here, but I am unsure as how to use it in this case?

Use the LOOKUP function with MATCH and ISNA:
=IF(ISNA(MATCH(A1,Sheet2!$A$1:$A$3,0)),"",LOOKUP(A1,Sheet2!$A$1:$A$3,Sheet2!$B$1:$B$3))

Related

Sorting row by row

I have a table in excel which has values like below
2 1 3
6 5 4
7 2 3
Considering the rows do not have a column header, what is the easiest way to sort them row by row, such that I get the below output
1 2 3
4 5 6
2 3 7
If the array starts in A1 please try (UNTESTED) in AB1 copied across 27 columns and down to suit:
=SMALL($A1:$AA1,COLUMN()-27)

Return list of matching rows

Sheet1
A B C D
1 2 3 4
2 4 5 6
3 3 5 6
4 7 3 1
5 4 6 7
Sheet 2
A B C D
1 4
2 1
3 1 3 4
4 1 2 5
5 2 3
6 2 3 5
7 4 5
Column A of Sheet 2 has a non repeating listing of all values in Sheet 1. I would like a forumla so Col B of Sheet 2 lists the value of Sheet 1 Col A for each row where the Sheet 2 Col A lookup value is found. Either giving me a comma sep list or putting the results in sheet 2 Col B,C,D,...
I came up with a solution, but it involves a handful of formulas, not just one. Hopefully, you will still find it useful.
Your Sheet2 would basically look like this:
Here are the formulas you need to enter:
B1: =IFERROR(SMALL($G4:$U4,COLUMN()-1),"") [drag down and across to D7]
G1: =IF(F2=$W2,F1+1,MAX(1,F1)) [drag across to U1]
G2: =IF(F2=$W2,1,F2+1) [drag across to U2]
G3: =INDEX(Sheet1!B$1:D$5,G1,G2) [drag across to U3]
G4: =IF(G$3=$F4,G$1,"") [drag down and across to U10]
What this does is organize the Sheet1 data into rows, where each row corresponds to a lookup value. Then, it grabs the smallest value, the second smallest value (if one exists), and third smallest value (if one exists) from each row.
This should be easy to scale to as large a spreadsheet as you need (as long as you don't run out of columns).

Comparing Multiple Cells and Returning Values

I have a spreadsheet that looks like this:
A B C D
1 Bob 10/02/2013 10
2 Bob 10/02/2013 2
3 Bob 10/02/2013 8
4 Steve 10/01/2013 6
5 Steve 10/01/2013 6
6 Sally 10/01/2013 6
The requirement is that if A1 matches anything else in column A (A1,A2, and A3) AND B1 matches anything in column B (B1,B2,B3) Then add up the values C, divide by 4 and put that in D.
I want to do this for the whole sheet (500ish rows).
You may use the SUMIFS function. Below is sample.
Formula =SUMIFS(C1:C5,A1:A5,A1,B1:B5,B1)
OR
Or can use SUMPRODUCT function .
=SUMPRODUCT($C$1:$C$5,--($A$1:$A$5=$A1)*--($B$1:$B$5=B1))/4

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.

Compare two columns in excel

Hey, I have an excel document with columns A and B. Row A has 2595 values. Row B has 411 values.
I'm trying to figure out how I can compare these two columns by marking column C with the number of times we find a value(s) from row a.
For Example
COLUMN A COLUMN B COLUMN C
1 1 1 (because we have one value of 1 from column A)
2 2 1 (because we have one value of 2 from column A)
3 3 2 (because we have 2 threes from column A)
3 4
4 5
5 6 2 (because there are two 6's in column A)
6 7 0 (because there are no 7's in column A)
6
I'm sure you can see where I'm going with this but for the life of me I cannot figure out how to do this, I've been searching around all morning. Help!
If needed I can supply the excel document.
You can use the COUNTIF function
Column A Column B Column C Answer
1 1 =COUNTIF($A$2:$A$9,B2) [1]
2 2 =COUNTIF($A$2:$A$9,B3) [1]
3 3 =COUNTIF($A$2:$A$9,B4) [2]
3 5 =COUNTIF($A$2:$A$9,B5) [1]
4 6 =COUNTIF($A$2:$A$9,B6) [2]
5 7 =COUNTIF($A$2:$A$9,B7) [0]
6
6
You can use COUNTIF. If A1:A8 is your search criteria, B1 is the value you're currently processing, C1 would be:
=COUNTIF(A1:A8;B1)

Resources