Count repetitive values in column B based on unique value in column A - excel

I have the following table:
1 John Doe
John Doe
2 Adam Smith
Adam Smith
Adam Smith
I need to count the number of times a name appears for each number value in column A. The numbers are unique.

Place this formula in cell C1 and drag down until the end.
=IF(ISNUMBER(A1),COUNTIF(B:B,B1),"")
n.b. - you can more clearly define row numbers instead of using B:B if you like as well

Related

Excel - Append cell2 to cell1 if cell3 is not blank

All,
I've taken a browse around and I've been unable to nail down the formula I'm looking for. I'm a bit new to Excel expressions, so this is all part of the learning process.
My quandary:
I have a list of names in an Excel spreadsheet - some have two components and some have three. I need all names to have only two components - if they have three, then the first two components need to be combined.
Here is my workflow:
IF cell 3 is occupied, append the content of cell 2 to the end of cell 1 IN cell 1. Then, assuming cell 2 is now blank, move the content of cell 3 to cell 2. Else, do nothing.
So my input might be (assuming each group of characters is in its own cell):
JOHN SMITH
JOHN DOE SMITH
BARRY JOHNSON
RICHARD P RICKSON
JACK JACK GILES
My output would be:
JOHN SMITH
JOHNDOE SMITH
BARRY JOHNSON
RICHARDP RICKSON
JACKJACK GILES
What's your take on this?
Assuming your data is in columns A, B, and C, this will put the correct output in columns D and E.
In column D:
=IF(ISBLANK(C1),A1,CONCAT(A1,B1))
In column E:
=IF(ISBLANK(C1),B1,C1)

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).

VLOOKUP to check if a value exists in a cell

I have data like this in a column:
John L. Doe
Jane N. Doe
Michael A. Doe
I'm trying to match the entries against another column with this format.
doe, jane
doe, john
doe, michael
I've tried VLOOKUP's for the lastname and using wildcards:
VLOOKUP("*" & A1 & "*",B:B,2, FALSE)
but I'm getting #N/A as a result.
If your columns are labelled, then in C2 and copied down to suit:
=MATCH(TEXT(MID(B2,FIND(" ",B2)+1,LEN(B2))&"*"&LEFT(B2,FIND(",",B2)-1),"#"),A:A,0)
should return the row number of a match in ColumnA for the value in ColumnB that is in the same row as the formula result.
To match "the other way around" is very similar, and as it happens for the example the results the same:
=MATCH(TEXT(MID(A2,FIND(" ",A2,FIND(" ",A2)+1)+1,LEN(A2))&"*"&LEFT(A2,FIND(" ",A2)-1),"#"),B:B,0)

If column has duplicate values then check duplicate in another column

I have two column I and N.
In column I have 6 digit numbers.
In column N have names.
I N R(Result)
123456 James BLANK
123456 Mike BLANK
111111 Jack Jack&111111
111111 Jack Jack&111111
000023 Mike Blank
000024 James James&000024
000024 James James&000024
I tried so far but not working
=IF(COUNTIF(I:I,I2)>1,IF(OR(N2=N1,I2=I1,I2=I3),CONCATENATE(I2," ",N2),""),"")
Try using the formula:
=IF(COUNTIFS(I:I, I2, N:N, N2)>1, I2&" "&N2, "")
COUNTIFS allows you to enter multiple criteria for the count, as opposed to COUNTIF.

Excel macro/formula - replace cell values if value does NOT appear in another column

I need help. I have a list of 20 names of certain consultants. I receive a new sheet daily with many names, and if one of them does not match with any of the 20 consultant names, I need to replace the cell value with "X".
E.g.
1. Consultant's list contains John and Mary.
2. Daily list contains 5 names: John, Steve, Dean, Mary and Sue.
3. I now want to replace all the cell which does NOT contain John and Mary with X (thus replace cell with names Steve, Dean and Sue with X)
Help will be appreciated
If your 20-name list is in ColumnA and the daily list in ColumnB each starting in Row1 then in Row 1 and copied down to suit:
=IF(ISERROR(MATCH(B1,A:A,0)),"X",B1)

Resources