Excel - Delete specific word in each row?

3

Is there a way to have Excel delete a sepcific word in every row? For example, each row says Mr. and Mrs. {first name} {last name}, and I want to delete the {first name} from each one. (Or alternatively, by extracting the first three words and the last word, and then combining them.)

Thanks!

Dave

Posted 2010-07-13T18:09:32.557

Reputation: 185

Answers

2

Here is my solution. Which uses in part this.

=LEFT(A6,FIND(" ",A6,FIND(" ",A6,FIND(" ",A6)+1)+1))&RIGHT(A6,LEN(A6)-FIND("@",SUBSTITUTE(A6," ","@",LEN(A6)-LEN(SUBSTITUTE(A6," ","")))))

This keeps the first 3 words and the last word and doesn't need to assume the first three words are "Mr. and Mrs.". If you do assume that you can use the shorter version:

="Mr. and Mrs. "&RIGHT(A6,LEN(A6)-FIND("@",SUBSTITUTE(A6," ","@",LEN(A6)-LEN(SUBSTITUTE(A6," ","")))))

Edit: using my top formula and this one (which just gives the first and last word):

=LEFT(A6,FIND(" ",A6))&RIGHT(A6,LEN(A6)-FIND("@",SUBSTITUTE(A6," ","@",LEN(A6)-LEN(SUBSTITUTE(A6," ","")))))

We can combine those with an if statement... I'm not sure what if statement would be best, but let me show you what one would look like where we count the number of "." in the statement. If it is 2 or greater, use the first 3 words and last, otherwise just the first word and the last.

IF(LEN(A6)-LEN(SUBSTITUTE(A6,".",""))>=2,LEFT(A6,FIND(" ",A6,FIND(" ",A6,FIND(" ",A6)+1)+1))&RIGHT(A6,LEN(A6)-FIND("@",SUBSTITUTE(A6," ","@",LEN(A6)-LEN(SUBSTITUTE(A6," ",""))))),LEFT(A6,FIND(" ",A6))&RIGHT(A6,LEN(A6)-FIND("@",SUBSTITUTE(A6," ","@",LEN(A6)-LEN(SUBSTITUTE(A6," ",""))))))

Edit2: If you want to use your -and- solution you can use this formula:

=LEFT(A6,FIND(" ",SUBSTITUTE(A6," and ","-and-")))&RIGHT(A6,LEN(A6)-FIND("@",SUBSTITUTE(A6," ","@",LEN(A6)-LEN(SUBSTITUTE(A6," ","")))))

Jarvin

Posted 2010-07-13T18:09:32.557

Reputation: 6 712

Wow, that's great. I was wondering how to deal with instances where there is only one title (e.g., only "Mrs."). My thought was to temporarily substitute " and " with "-and-", so that all titles are treated as a single word; then keep the first and last words; and finally, switch "-and-" back to " and ". Presumably there is a way to incorporate this into the formula, but I don't even know where to start. Thanks! – Dave – 2010-07-13T22:28:46.940

Your last solution is exactly what I need. Thanks again! – Dave – 2010-07-15T14:15:23.933

2

Here is the formula for finding the third word, but it's a long one:

=MID(MID(MID(SUBSTITUTE(A1," ","^",3),1,256),FIND("^",SUBSTITUTE(A1," ","^",3)),256),2,FIND(" ",MID(MID(SUBSTITUTE(A1," ","^",3),1,256),FIND("^",SUBSTITUTE(A1," ","^",3)),256))-2)

Reference Link here.

Now, put this in one column, click and drag, then create a second column that removes this word.

Actually, in your specific case, you can just use this formula, in this example, A1 has the string and C1 is where the formula above is:

=LEFT(A1, 13) & RIGHT(A1,LEN(A1) - (13 + LEN(C1)))

And, of course, you could substitute the entire first formula for C1, to get it all in one formula.

Lance Roberts

Posted 2010-07-13T18:09:32.557

Reputation: 7 895

This assumes the first 3 words are 13 characters. – Jarvin – 2010-07-14T14:43:07.530

@Dan, yes, that's why I said in your specific case. – Lance Roberts – 2010-07-14T15:20:07.687

1

all the solutions above are amazing; however, a nice way of doing this (Assumint Mr. John Smith is in one column) is to do tools to columns from the Data menu and use space as a delimiter

dassouki

Posted 2010-07-13T18:09:32.557

Reputation: 982

Great! Also you can use a function to take the string after the first space character. – kokbira – 2010-07-14T15:55:27.670

0

Ctrl+F, choose replace, put "Mr. " (do not forget the space character) and in replace with must be empty. Then replace all.
Ctrl+F, choose replace, put "Mrs. " (do not forget the space character) and in replace with must be empty. Then replace all.

That solution is fast for few words to replace, but must be used only with words that are not inside a name (with "James Amr. Kohn" for example; in this case, pehaps "case sensitive" option solves it).

kokbira

Posted 2010-07-13T18:09:32.557

Reputation: 4 883

0

I'd use the Ctr+F and use the replace tool, simply type the word you want to remove then click replace - this will replace your chosen word with nothing!

Kieran

Posted 2010-07-13T18:09:32.557

Reputation: 1