Add salutation to a surname

Issie_52

New Member
Joined
Jul 22, 2013
Messages
32
Good day,

I am trying to add Mr & Mrs to a formula. I have a long list of names, both single (Mr J Smith) and married couples (Mr AB & Mrs CDE Smith)

Currently the formula looks like this:
=IFERROR("Dear "&LEFT(A5,FIND(" ",A5,1)-1)&" "&RIGHT(A5,LEN(A5)-FIND("*",SUBSTITUTE(A5," ","*",LEN(A5)-LEN(SUBSTITUTE(A5," ",""))))),"-")
resulting in: Dear Mr Smith

I need it to read Dear Mr & Mrs Smith.

Any feedback/help will be appreciated.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
try

Code:
=IF(ISNUMBER(SEARCH("Mrs",A5)),"Dear Mr & Mrs "&TRIM(RIGHT(SUBSTITUTE(A5," ",REPT(" ",500)),500)),"Dear Mr "&TRIM(RIGHT(SUBSTITUTE(A5," ",REPT(" ",500)),500)))
 
Upvote 0
Hi Issie,

Try this formula:
=IFERROR("Dear "&LEFT(A5,FIND(" ",A5,1)-1)&" "&IFERROR(IF(SEARCH("Mrs",A5)>0,CHAR(38)&" Mrs ",""),"")&RIGHT(A5,LEN(A5)-FIND("*",SUBSTITUTE(A5," ","*",LEN(A5)-LEN(SUBSTITUTE(A5," ",""))))),"-")

N.B. If you have values such as "Miss" "Ms" etc it won't pick it up currently, you'll need to adjust the formula
 
Upvote 0
try

Code:
=IF(ISNUMBER(SEARCH("Mrs",A5)),"Dear Mr & Mrs "&TRIM(RIGHT(SUBSTITUTE(A5," ",REPT(" ",500)),500)),"Dear Mr "&TRIM(RIGHT(SUBSTITUTE(A5," ",REPT(" ",500)),500)))

more compact version

Code:
="Dear Mr "&IF(ISNUMBER(SEARCH("Mrs",A5)),"Mrs ","")&TRIM(RIGHT(SUBSTITUTE(A5," ",REPT(" ",500)),500))
 
Upvote 0
You may need to adjust for a single lady eg Mrs J Smith
[TABLE="width: 152"]
<colgroup><col width="152"></colgroup><tbody>[TR]
[TD="width: 152"][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
You may need to adjust for a single lady eg Mrs J Smith
[TABLE="width: 152"]
<colgroup><col width="152"></colgroup><tbody>[TR]
[TD="width: 152"][/TD]
[/TR]
</tbody>[/TABLE]

we need to know how many others to work on

Mr
Mrs
Miss
Ms
Dr
Lord
Lady

etc
etc
 
Upvote 0
This seems to work regardless of the salutation provided the ampersand is used to join the two people:

=TRIM(LEFT(SUBSTITUTE(A5," ",REPT(" ",99)),99)&IFERROR(" "&MID(SUBSTITUTE(A5," ",REPT(" ",99)),FIND("&",SUBSTITUTE(A5," ",REPT(" ",99))),99*2),"")&RIGHT(SUBSTITUTE(A5," ",REPT(" ",99)),99))
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top