Excel: Finding Difference in Two Lists - excel

Say I have two lists in two columns in an Excel Worksheet...
Column A
Apple
Baseball
Carlos
Dad
and...
Column B
Baseball
Dad
Visual
Basic
I'm trying to compare what is in column A with what is in column B to find out what is in column A but not column B.I have a formula that works here that I can put in column C
=IF(COUNTIF($B:$B, $A2)=0, "No match in B", "")
My issue is how do I apply that formula to every row where Column A has an entry, and while doing that changing the $A2 in the formula to the corresponding row it's in. I can manually do this by going through and copying and pasting the formula to column C and changing $A2 to $A3,$A4 etc. Hoping theres a quick fix here so I don't have to do it for 400 rows!

Enter the below formula in Column C and drag down. You formula can be much simplified as below,
=IF(COUNTIF(B:B,A1),"Match","No Match")
COUNTIF returns a true if a match has been found, or in other words if the result is greater than 0. Returns false (0) if there is no match. Hence this can be written as mentioned above. (Checking if it is equal to 0 would not be necessary)
You could just drag the fill handle to as many rows you have.

Related

Complicated Find row in duplicate show which column A or B or C

Could you please help me for below formula little bit complicated
Problem is
In a sheet I have three column A,B,C any one column amount if it is same in D column need to highlight and show which column A or B orC..
Example
A B C D amount in each row
4 5 7 4 please highlight bez a and d match
Next example
5 3 6 2 should not highlight show error msg
In above case D is matching same number with AorBorC
Please help me this logic formula
Formula
=If(countif(A1:d4)=1, "duplicate","unique")
working fine but is there any possibility to show which cell column A or B or C ... If duplicate which column need to mention
Much appreciated for this complicated formula am not sure whether it required VBA here
Your question mentions "Highlight", so here's that part of the solution. Select your first 3 columns of data (A1:C6 in my case). Then go to Conditional Formatting in the Home Tab. Create New Rule, using a Formula to determine which cells to format.
Here's the formula:
=A1=$D1
Change the format fill to your color of choice. Click OK.
EDIT - Adding the last piece here...
Lastly, to display which column(s) match column D value, you could use a formula such as this.
Cell E1 Formula:
=CONCAT(IF(A1=D1,"A",""),IF(B1=D1,"B",""),IF(C1=D1,"C",""))
Drag it down.
XLOOKUP unlike VLOOKUP returns a reference to the cell and not just the value of the cell.
With this in mind =XLOOKUP(D2,A2:C2,A2:C2,NA()) will return the value if it exists as well as the reference.
If we wrap the Return Array with the Column function it will return the column number.
=XLOOKUP(D2,A2:C2,COLUMN(A2:C2),NA())
Add the ADDRESS function to return the cell address (this will return the address on row 1)
=XLOOKUP(D2,A2:C2,ADDRESS(1,COLUMN(A2:C2),4),NA())
Now substitute the 1 in the cell address with a blank:
=SUBSTITUTE(XLOOKUP(D2,A2:C2,ADDRESS(1,COLUMN(A2:C2),4),NA()),"1","")

Excel lookup for single and multiple criteria together

I have 10000 rows of data in excel in column A & B and a new sheet with all data from column A. What i want to do a VLOOKUP from sheet 1 to sheet 2. But there are few examples in column A with 2 values in B.
Example:
Sheet 1
In sheet 2 if VLOOKUP is done for orange I am expecting 20,30
I have tried single criteria =VLOOKUP(A2,sheet2!a1,false) which worked for apple
Any suggestions how both the expected results can be done together
Not sure if it helps, but here's a solution with the formula:
Array formula in cell E2 (Ctrl+Shift+Enter):
=SUMPRODUCT(LARGE((--(IF(LEN($A$2:$A$6),$A$2:$A$6,OFFSET($A$2:$A$6,-1,0))=$D2))*($B$2:$B$6),1))
In column F you need to replace "1" (at the very end of the formula) with number "2".
A few notes:
your data set cannot start in row 1, otherwise OFFSET formula won't work.
both formulas (columns E & F) are looking for the 1st and 2nd largest number which matches the argument (column D). If the second one doesn't exist, it returns 0.
However, given the size of your data set, it is worth considering a VBA solution.
Edit: adjusted for column B = text
Use the following Array formula in cell E2 (Ctrl+Shift+Enter):
=IFERROR(INDEX($B$2:$B$6,SUMPRODUCT(LARGE((--(IF(LEN($A$2:$A$6),$A$2:$A$6,OFFSET($A$2:$A$6,-1,0))=$D2))*(ROW($B$2:$B$6)),1)-1)),"")
Similar Array formula in cell F2 (Ctrl+Shift+Enter):
=IFERROR(INDEX($B$2:$B$6,SUMPRODUCT(LARGE((--(IF(LEN($A$2:$A$6),$A$2:$A$6,OFFSET($A$2:$A$6,-1,0))=$D2))*(ROW($B$2:$B$6)),2)-1)),"")
Result:

Sorting and finding duplicates in excel columns

I have five columns in my spreadsheet, three of which are filled with assorted names( the first, fourth and fifth columns).
I need a way to cross-reference each cell in the A column with the D and E columns, then have an output that answers the question in the B and C column (which you can see as the Xs), as to whether it was found. I've tried a combination of VLOOKUP and MATCH, but this is proving to be out of my realm. I haven't used excel much lately.
EDIT: Added a picture instead of a diagram
In Cell B3 use =IF(COUNTIFS(D:D,A:A),"","X")
and in C3 use =IF(COUNTIFS(D:D,A:A),"","X")
copy down as far as required
Formula says "If count of names in D:D equal to name in current row in A:A is > 0 then return blank, else return "X"
Test is case-insensitive.

search for 2 parameters in column and returning a third column

I am trying to search from inside spreadsheet 1 into spreadsheet 2 for 2 things that must be true and if so, pull back another column row.
I want to search column A for the number 12345 and column B for the string "GBP" but I do not know what row 12345 and "GBP" will occur on. If found (there can only ever be 1 result returned so don't worry about multiple results) I need to return the value in column C.
The thing is - I am finding this tricky. Can you help me please?
Create a column C where each cell to the right of data contains the formula
=IF(AND(A2=12345,B2="GBP"),1,0)
When you have copied that formula into each cell down the entire column, search that column for a "1". The "1" is what you are looking for.
As long as there is 1 row matching the criteria, you can use SUMIFS function to get the value from the matching cell:
assuming A2=12345 and B2="GBP" on the current sheet,
sum all values on Sheet 1 column C where both columns A and B match the specified criteria:
=SUMIFS(Sheet1!C:C,
Sheet1!A:A, A2,
Sheet1!B:B, B2)

Excel - Find a value in an array and return the contents of the corresponding column

I am trying to find a value within an array and then return the value in a specific row in the corresponding column.
In the example below, I need to know which bay the Chevrolet is in:
Column A Column C Column D Column E
Chevrolet Bay 1 Bay 2 Bay 3
Toyota Ford Saturn
Honda Chevrolet Jaguar
Ferrari Subaru Lexus
Mitsubishi Hundai BMW
I am looking for Chevrolet in the array C2:E5. Once it determines that the Chevrolet is in Column D, I need for it to return the value in D1. If it was in column E, I need it to return the value in E1.
Any help would be greatly appreciated. Thank you so much in advance.
Try this Array Formula:
=INDEX($C$1:$E$5,1,SMALL(IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99),1))
or if you are sure that each column contains exactly what's being searched it can be written like this:
=INDEX($C$1:$E$5,1,SMALL(IF($C$1:$E$5=A1,COLUMN($A:$C),99^99),1))
Enter formula in any cell by pressing Ctrl+Shitf+Enter.
How does it work?
Our ultimate goal is to find the Column that contains the match:
First we did the search for the match using this formula: SEARCH(A1,$C$1:$E$5). It just checks if any of the entries matched A1. Actually, it can be simplified to $C$1:$E$5=A1 but I'm not sure if all entries in each column match exactly what's in A1.
That formula will produce an array of values when entered as array formula. Something like: {SEARCH(A1,C1), SEARCH(A1,D1), SEARCH(A1,E1);... SEARCH(A1,E5)}. The result will be array of number(s) and error (if non was found). But we don't want that, else we will be returning error everytime.
We then use IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99). This formula returns the Column Number if there is a match and a relatively huge number 99^99 otherwise. Result would be: {99^99, 99^99, 99^99, 2, ..., 99^99}.
And we are close to what we need since we already have an array of Column and huge number. We just use SMALL to return the smallest number which in my opinion is the lowest Column Number where a match is found. So SMALL(IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99),1) would return 2. Which is the column where Chevrolet is referenced at $C$1:$E$1.
Since we already have the column number we simply use INDEX Function which is: INDEX($C$1:$E$5,1,2).
Note: 99^99 can be any relatively large number. Not necessarily 99^99. Actual 16385(max column number in Excel 2007 and up + 1) can be used.
Result:
Another quick and dirty answer is to put a "dummy" row above the entire data set and then determine which placeholder column returned the correct result.
In B1, you can put the equation
=MATCH($A$2,B3:B6,0)
And then in C1, you can put
=MATCH($A$2,C3:C6,0)
And so on until you've covered all the rows and columns. Change the B3:B6 & C3:C6 to reflect the actual rows of data in the given column.
Now, the fun array formula which will actually return the bay. I have this array formula in cell A1 and it is looking from B1:D1, but you can move cell A1 anywhere you want and the B1:D1 range should be all the dummy columns you made above. Also, this is assuming that the bays you want are in row 2 (if they are in a different row, change R2C to R#C where # is the row number). In order to properly enter, enter the formula and then press CTRL+SHIFT+ENTER.
=INDIRECT("R2C"&SUM(IF(ISERROR(B1:D1),FALSE,B1:D1))+1,FALSE)
If the formula is entered properly, it will show curly brackets { } around the equation when you single click on the cell.
This formula will do it, assuming that the lookup value is in A1:
="Bay "&SUMPRODUCT((B2:D5=A1)*(COLUMN(B2:D5)))-1
You could easily adjust it to add more rows and columns.
The formula returns the column number that contains the lookup value and concatenates it with the word Bay to return the exact result you want.
The -1 at the end adjusts for the fact that the Bay 2 column is actually the third column in the worksheet, so you might need to adjust that offset as well.
The SUMPRODUCT function is much undervalued. More on it here:
http://fiveminutelessons.com/learn-microsoft-excel/multiply-two-columns-and-add-results-using-sumproduct
The SUMPRODUCT formula above is perfect for what I want.
E.g. to find the location - COLUMN and ROW - of a given value at A1 in a 2D Range A2:J44
use: =SUMPRODUCT((A2:J44=A!)*(COLUMN(A2:J44))) gives the Absolute* COL#
and : =SUMPRODUCT((A2:J44=A1)*(ROW(A2:J44))) gives the Absolute* ROW#
(not where it is in the range)
These can then be used in e.g. INDEX() or CELL() etc functions.

Resources