How can excel highlight matching entries between 2 tables/4 columns - excel-formula

I am trying to find the duplicates between Table 1 and Table 2. The entires in column 'A' and 'B'together has to match the entries in column 'C' and 'D'
Looking for a formula that will highlight the duplicates in the given scenario.
![Table 1 has 2 columns, A and B. Table 2 has two columns, B and C. The formula should highlight the text in A and B together to text in B and C together][using excel]

Maybe create "key" columns to make things easier: Column X = A & B, Column Y = C & D
Then you can either use vlookup(A&B,Y...) or vlookup(C&D,X...)
Or Match(A&B, Y...( etc will give you the row number which could be useful, plus is a lot quicker than vlookup if you have heaps of rows (plus you don't need to lookup anything so why not? Or even if you did Index(Match..)) is still quicker...
Or you could even use Countif(A&B, Y) and vice versa...
Thats a hell of a lot of pseudo formulas lol so maybe something like:
Sheet2.D1 Formula: "=CountIf(Sheet1!$C$1:$C$1000, A1 & B1)" and do the same on the other:
Sheet1.D1 Formula: "=CountIf(Sheet2!$C$1:$C$1000, A1 & B1)"
Sheet1!C1 Formula = "=A1 & B1"
Sheet2!C1 Formula = "=A1 & B1"
Or if you only have one duplicate and want to know the row number:
Sheet1.D1 Formula: "=If(isna(match(A1 & B1,Sheet2!$C$1:$C$1000,0)),"","Duplicate on row: " & match(A1 & B1,Sheet2!$C$1:$C$1000,0))"

Related

Matching multiple value in excel using index and match

I used index and match to identify the values of the table and matched it. However I am facing trouble when I try to get b and c, a is matched correctly
A. B C D.
1 a b c
2 fruit1 a
3 fruit0
4 fruit3
5 fruit5 a
E F
1 fruit1 a
2 fruit0 c
3 fruit3 b
4 fruit5 a
My formula is
=Iferror(if(index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)) = b$2,index(($f$1:$f$4), match($A2,$e$1:$e$4,0),match(b$2,$f$1:$f$4,0)), ""),"")
If your data table is in E1:F4, and you are trying to look up the fruit names that appear in column A starting at A2, and place the correct letter next to them in column B, then there's no need for the IF and the sequences of MATCHes.
All you need is this, pasted into cell B2 and copied down, is this:
=IFERROR(INDEX($F$1:$F$4,(MATCH(A2,$E$1:$E$4,0))),"")
An easier approach to this is just:
=VLOOKUP(A2,$E$1:$F$4,2,FALSE)
or to be safer:
=IFERROR(VLOOKUP(A2,$E$1:$F$4,2,FALSE),"")
And if you have access to O365 Excel and the newer XLOOKUP function, you can use the following examples. XLOOKUP incorporates the "not found" result so you don't have to do a separate IFERROR. Do do it on a cell-by-cell basis as you had before, put this in B2 and copy it down:
=XLOOKUP(A2,$E$1:$E$4,$F$1:$F$4,"",0)
If you want to go one step further, you can apply the XLOOKUP as an array or "spill" formula, you change the lookup_value to be the A1:A4 and it does the rest. Place this in B2 and it will fill B2 through B5:
=XLOOKUP(A2:A5,$E$1:$E$4,$F$1:$F$4,"",0)

Formula to Return Text in the Row of Largest Number

Column A Has Text & Columns B, C & D contain numbers.
For Ex.)
A... …B C D
John 4 6 2
Dave 4 6 4
Mike 4 5 1
Bill 2 5 9
I would like a cell to return the name in column A that has the Largest Number in Column B. And if there are similar numbers, go to the next column and determine which is highest, and if that is tied go to the next column and so on.
Any help would be appreciated.
We can de-conflict ties.In E1 enter:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))
and copy down. Then in another cell enter:
=INDEX(A:A,MATCH(MAX(E:E),E:E,0))
EDIT#1
This is only good for 3 columns of numbers, but it is very easy to add additional de-confliction terms if necessary:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))+E1/(1000*MAX(E:E))
For an expandable number of rows/columns, use a helper row with the same number of columns as number columns in your data. The formulas below reference the following image (the data are in A1:G7):
B9-->=MAX(B1:B7)
C9 (fill over the remaining columns to G9)-->
=MAX(IF(MMULT(--($B1:B7=$B9:B9),--(ROW(INDIRECT("1:"&COLUMNS($B9:B9)))>0))=COLUMNS($B9:B9),C1:C7))
The following formula will give the answer (shown in A9 above):
=INDEX(A1:A7,MATCH(TRUE,(MMULT(--($B1:G7=$B9:G9),--(ROW(INDIRECT("1:"&COLUMNS($B9:G9)))>0))=COLUMNS($B9:G9)),0))
UPDATE WITH ALTERNATIVE METHOD
Using a helper column instead, again referencing the image below (the data are in A1:G7):
I1 (fill down to I7)-->
=SUM(--(MMULT(SIGN(B1:G1-$B$1:$G$7)*2^(COLUMN(G1)-COLUMN(A1:F1)),--(ROW(INDIRECT("1:"&COLUMNS(B1:G1)))>0))>0))
The following formula will give the answer (shown in J1 above):
=INDEX(A1:A7,MATCH(MAX(I1:I7),I1:I7,))
As a bonus, notice that the helper column corresponds to the order that you would get from sorting the data by each column left-to-right. In other words, you could use the helper column to perform a formula-based multi-column sort on strictly numeric data. For the last image, entering the following array formula into a range with the same dimensions as A1:G7 gives a descending sort on columns B through G:
=IF(A1:A7=A1:A7,INDEX(A1:G7,MATCH(ROW(A7)-ROW(A1:A7),I1:I7,0),))

Highlight cells based on the value of cells in another column

I have this problem as noted below:
Column A = Part number
Column B = Quantity
Column C = Part number
Column D = Quantity
Using conditional formatting, I would like to highlight if the combination of Part number and Quantity in Column A and B is different to the combination of Part number and Quantity in Column C and D.
Eg:
Col A Col B Col C Col D
1 1111 2 1112 5
2 1112 3 1111 2
3 1131 5 1112 5
4 1122 3 1131 2
To do this, I'd like to set up a couple of 'helper' columns (say E & F) by concatenating Column A & B, C & D.
So essentially, I'd like to take the information from the helper columns E & F, but use conditional formatting to highlight the cell in column B and D.
From the example above, cell B3 and D4 would be highlighted.
Is this possible, and if not, is there are simple alternative? (I don't mind using a macro if need be).
I would use COUNTIFS
For B1:B4
=COUNTIFS($C$1:$C$4,A1,$D$1:$D$4,"<>"&B1)
and for D1:D4
=COUNTIFS($A$1:$A$4,C1,$B$1:$B$4,"<>"&D1)
In case you even want to skip the helper columns, you could format A1 with =$A1&$B1<>$C1&$D1 and copy the format to any cells in you want to be highlighted (even to your helper columns).

excel counting + matching 3 columns

I have a log where I have two columns (H&G) where I have sales people's names inputted for each row. Column I lists the row as belonging to one of three categories ("name1" "name2" or "name3").
On the next sheet in the book I have tabulations for counting how many times each person's name appears, but what I'd like to do is cross reference that with how many they appear next to each of the categories.
ie I currently can tell that Steve has 6 deals. But what I'd like to know is that Steve has 4 of name1 and 1 each of name2
edit:
So I think I've not been clear on what I'm searching for: I am trying to sum the number of times a salesperson's name appears in columns F or G that also have a string in column H.
ie: Steve's name appears 13 times, but only 8 of those are on rows that have Phone
Assuming your data is as in the image below, try following formula
=COUNTIFS($F2:$F9,J2,$H2:$H9,K2)+COUNTIFS($G2:$G9,J2,$H2:$H9,K2)
Drag/Copy down formula as required and change range as per your data.
In above formula I am assuming you want to consider Column F and column G separately for category. In case you want both Column H & G to have same name for category then use
=COUNTIFS($F2:$F9,J2,$G2:$G9,J2,$H2:$H9,K2)
This will give result 1 as only Row 5 has Steve in both Column F & G matching category Phone.
EDIT : As per #ForwardEd's comment
If you want to count row having same Name in both Column F & G only once (as in Row 5 in image), then subtract above two formulas as
=COUNTIFS($F2:$F9,J2,$H2:$H9,K2)+COUNTIFS($G2:$G9,J2,$H2:$H9,K2)-COUNTIFS($F2:$F9,J2,$G2:$G9,J2,$H2:$H9,K2)
or use
=SUMPRODUCT((($F$2:$F$9=J2)+($G$2:$G$9=J2)>0)*($H$2:$H$9=K2))
This will give result 3 for Name=Steve and Category=Phone considering Rows 2,5,8 (note : Row 5 has Steve in both Column F & G but will be counted once).
Use COUNTIFS:
=COUNTIFS(A1:A6,"steve",B1:B6,"name1")
For referencing from multiple sheets:
=COUNTIFS(A1:A6, "steve", Sheet2!A1:A6, "name1")
you can make n columns for each column you'd like to know and or you can make a single big column with multiple formulas.
You can use the & symbol to string together a long formula in a single cell.
Like:
="Month 1: "& countif(G1:G10,"Steve") & " " & "Month 2: "& countif(H1:H10,"Steve")
All that will output: Month 1: 4 Month 2: 2
you can string a lot of functions with the & symbol, so you can change the placeholder and stuff.
Also you can change the inquote string "Steve", for a reference so you'll just have to write this big formula once.

How to concatenate columns in excel using a formula having conditions?

I want to concatenate columns A, B, C and D in column E. But the concatenated cell should contain the data of all the columns with some extra text.
e.g. Suppose column A contains "11/01/1997", B contains "ABC", C contains "20" and D contains "B+". Then E should contain "DOB: (data of A column), Name: (data of B column)" and so on.
Unless I have misunderstood:
In the top row with data in (could be row 1 or row 2 if you have headers on the data)
Put = "DOB:" & A1 & ", Name: " & B1 ...
(Substitute 1 for 2 or whatever row you are on)
Drag this formula down the e column - this should do it for each row.
Ok?

Resources