Excel Find formula split string of names - excel

I'm trying to split a list of names, They in the form of:
Surname, Title. Firstname (Nickname)
Jonesy, Mr. Cheese (Edam)
Bukowski, Mrs. Gertrude (Gerti)
I need to put them into Firstname Surname
It should be easy to pick up the Firstname: Two characters after the dot of Title up to the space before the left bracket of Nickname. Only my excel formula doesn't give me what I want.
A1 Smith, Mr. Andrew (Andy)
A2 =MID(A1,1,Find(" ",A1)-2)
A3 =MID(A1,Find(".",A1)+2, Find("(",A1)+1)
Only for A3 I get:
Andrew (Andy)
Instead of just the name Andrew
I'll add the caveat that I need the formula to refer to the name cell and not an cell with temp data to be referenced (ie an interim cell)
I can't see the woods for the trees on this one. Need to call in a bigger brain.

Assuming a data setup where headers are in row 1, with your "Complete Name" in column A starting in row 2, like so:
In cell B2 and copied down is this formula to get the first name:
=MID(A2,FIND(".",A2)+2,FIND("(",A2)-FIND(".",A2)-3)
In cell C2 and copied down is this formula to get the last name:
=LEFT(A2,FIND(",",A2)-1)

You can use this single formula to get the Firstname Surname:
=TRIM(MID(A1,SEARCH(".",A1)+1,SEARCH("(",A1)-SEARCH(".",A1)-1))&" "&MID(A1,1,FIND(" ",A1)-2)

Pretty Simple I think....(Famous last words).
You had:
A1 = Smith, Mr. Andrew (Andy)
A2 =MID(A1,1,Find(" ",A1)-2)
A3 =MID(A1,Find(".",A1)+2, Find("(",A1)+1)
I replaced the A# Find "(" with " " and it worked.
A1 = Smith, Mr. Andrew (Andy)
A2 =MID(A1,1,Find(" ",A1)-2)
A3 =MID(A1,Find(".",A1)+2, Find(" ",A1)+1)
This will only work if you have a single Firstname though. A name like Bobby Joe or Billy Bob will cut off at Bobby and Billy.

Related

Excel: Find the Position/Location of Each Occurrence of a Specific Word in a String in a Column

Using an MS Excel formula, I would like to find the Position(s)/Location of specific words found within a String of text located in a Range/Column of cells.
I'm using a formula that only identifies and finds the position(s) of a keyword by a single cell versus a column. I'm not able to repeat this action by looking throughout the column cells, using my numeric helper column (Cell D2:D12 "Occurrence") which provides the occurrence of the next position to be found.
Helper columns are welcomed if necessary to achieve the desired results.
The cells highlighted in "Red" is what I'm looking for as the final output results.
See below for formulas used for Column C and D. Text string is located in Column A2:A12.
COLUMN A
DATA TEXT
Dolly would not count her eggs but Count her apples
Tony drove a pickup truck to work
Over many nights he could not sleep
Only this and nothing more
She went by to pickup her son
To many times he would count over
They went shopping for Christmas
You can count him to pickup someone
They count so much they would sleep in his pickup
Nobody would play with Timmy
Trying to find the position location of each word
COLUMN B
Keyword List
Toe
Shoe
Count
Pumpkin
Pickup
Randy
Sally
Sleep
Jonathan
C2: =SUMPRODUCT((LEN($A$2:$A$12)-LEN(SUBSTITUTE((UPPER($A$2:$A$12)),UPPER(B2),"")))/LEN(B2))
D2&E2: =FILTER(B2:C10,C2:C10>0)
F2: =IF(E2="","",REPT(D2&"^",E2))
G2: =TEXTJOIN("",TRUE,F2:F4)
H2: =TRIM(MID(SUBSTITUTE($G$2,"^",REPT(" ",LEN($G$2))),(COUNTIF($H$1:H1,"<>&""")-1)*LEN($G$2)+1,LEN($G$2)))
I2: =IF(H2="","",IF(COUNTIF($H$2:H2,H2)>1,SUM(I1+1),1))
Try the below picture set up and formulas solution as in.
1] C2 "Total occurrence", formula copied down :
=SUMPRODUCT(LEN($A$2:$A$12)-LEN(SUBSTITUTE(LOWER($A$2:$A$12),LOWER(B2),"")))/LEN(B2)
2] D2 "Count", formula copied across to F2"Sleep" and all copied down :
=SUMPRODUCT(LEN($A2)-LEN(SUBSTITUTE(LOWER($A2),LOWER(D$1),"")))/LEN(D$1)
3] G2 "Keywords" , formula copied down:
=LOOKUP(ROW(A1),SUMIF(OFFSET(C$1,,,ROW($1:$12),),"<>")+1,B$2:B$4)&""
4] H2 "Occurrence", formula copied down:
=IF(G2="","",COUNTIF(G$2:G2,G2))
5] I2 "Content Keyword Data Text", formula copied down:
=IF(G2="","",LOOKUP(H2,SUMIF(OFFSET(INDEX($1:$1,MATCH(G2,$1:$1,0)),,,ROW($1:$12),),"<>")+1,$A$2:$A$12))
6] J2 "Position", formula copied down:
=IF(G2="","",FIND("~",SUBSTITUTE(LOWER(I2),LOWER(G2),"~",COUNTIFS(G$2:G2,G2,I$2:I2,I2))))

How to compare two excel sheets list?

I have two sheets list both has the same data which is first name and last name. I want to know if list A has the same last name, and the first 3 character from first name from list B. I tried to use Vlookup function but I did not work. I want to match exact last name and exact three character from first name.
An example:
Worksheet 1
A B
1 John Smith
2 Jane Jones
3 Robert West
Worksheet 2
A B C
1 John Smith MATCH
2 Jane Jones MATCH
3 Bob West NO MATCH
In cell C1 on Worksheet 2 enter this formula as an array formula:
=IF(NOT(ISNA(MATCH(CONCATENATE(LEFT(A1,3),B1),CONCATENATE(LEFT(Sheet1!$A$1:$A$3,3),Sheet1!$B$1:$B$3),0))),"MATCH","NO MATCH")
Drag your formula down to include cells C2 and C3.
Notes
To enter as an array formula use CTRL + SHIFT + ENTER
Update the Left formula to match different numbers of characters in first name

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)

Excel Find Nth Instance of Multiple Criteria

I have 3 columns of data. Col A contains Names, Col B contains a client ID, Col C contains a date.
I'm trying to figure out how to write a formula that will find the top 2 and top 3 instances of a specific Name in Col A and client ID in Col B and return the value in Col C.
Trying to avoid using VBA, but not sure if this is doable.
So for example data looks like this and I would want to return that Sam dealt with Client ABC the 2nd time around on 12/16.
Sam ABC 12/3
Adam XYZ 12/5
John DEF 12/9
Sam ABC 12/16
Adam HIJ 12/18
Assuming
your headers are in A1:C1
your data starts from A3 (yes, not A2)
You enter the name in G2 & Client ID in G3 & you want the list of
dates starting from G5
Enter these formula/values:
A2: =G2
B2: =G3
C2: =0
G5:
=IFERROR(INDEX(($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500),MATCH(0,COUNTIF($G$4:G4,($A$2:$A$500=$G$2)*($B$2:$B$500=$G$3)*($C$2:C$500)),0)),"End")
(Formula in G5 is an array formula; confirm this with Ctrl+Shift+Enter)
Drag the formula in G5 down until you see 'End'
Value in cell G5 will always be 0 or '1/0' based on your formatting.
The list of dates corresponding to the name & client ID combination will start from G6.
Let me see if I understood your need. Correct me if I'm wrong.
You want to be able to inform a Name and a Client ID and have Excel tell you the last 3 occurrences of that combination?
By "top 2 and top 3 instances of a specific name" I'm assuming you mean the top 2 and 3 dates found for that specific name and ID.
If so, try this:
Supposing you have your example data table starting at Cell A1 and ending at Cell C6 (including column headers) and that you'll enter the name in F1 and Client ID on F2
A B C
1 Name Client ID Date
2 Sam ABC 12/3
3 Adam XYZ 12/5
4 John DEF 12/9
5 Sam ABC 12/16
6 Adam HIJ 12/18
Type this formula where you want to return the date of the last occurrence:
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),1),"-")
This should be entered as an Array Formula, so don't forget to press CTRL + SHIFT + ENTER or it'll not work.
To bring the 2nd last occurrence on another cell, just copy and paste the formula and change the number 1 to 2 (as indicated below):
=IFERROR(LARGE(IF($A$2:$A$6=$F$1,IF($B$2:$B$6=$F$2,$C$2:$C$6)),2),"-")
If you typed 'Sam' on F1 and 'ABC' on F2, this formula would return '12/16' as the last occurrence, '12/3' as the 2nd last occurrence and a dash (-) as the 3rd last occurrence, since there isn't one.
Of course, you'll have to adjust the ranges and other cell references accordingly in your real data set.
Hope this helps.

How do I combine the first character of a cell with another cell in Excel?

I have an Excel sheet with first names in Column A and surnames in Column B. I want to create a third Column C that contains the first character from the first name and adds it to the surname, creating first initial + surname.
First Name Last Name Combined Name
John Smith jsmith
How can I do this using Excel?
=CONCATENATE(LEFT(A1,1), B1)
Assuming A1 holds 1st names; B1 Last names
Personally I like the & function for this
Assuming that you are using cells A1 and A2 for John Smith
=left(a1,1) & b1
If you want to add text between, for example a period
=left(a1,1) & "." & b1
Use following formula:
=CONCATENATE(LOWER(MID(A1,1,1)),LOWER( B1))
for
Josh Smith = jsmith
note that A1 contains name and B1 contains surname
This is what formula I used in order to get the first letter of the first name and first letter of the last name from 2 different cells into one:
=CONCATENATE(LEFT(F10,1),LEFT(G10,1))
Lee Ackerman = LA
Not sure why no one is using semicolons. This is how it works for me:
=CONCATENATE(LEFT(A1;1); B1)
Solutions with comma produce an error in Excel.
QUESTION was: suppose T john is to be converted john T, how to change in excel?
If text "T john" is in cell A1
=CONCATENATE(RIGHT(A1,LEN(A1)-2)," ",LEFT(A1,1))
and with a nod to the & crowd
=RIGHT(A1,LEN(A1)-2)&" "&LEFT(A1,1)
takes the right part of the string excluding the first 2 characters, adds a space, adds the first character.

Resources