Extract and Repost Names

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
326
Office Version
  1. 365
Platform
  1. Windows
I AM working on a large geneoly project. I need to extract the names from a string and reposittion them if married Example: Jill [Jack Jackson] needs to be redone to say Jackson (Jack and Jill). The names always appear in that layout.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Do you need the formula to check if they are married?

If not try
Code:
=TRIM(MID(RIGHT(A1,LEN(A1)-SEARCH("[",A1)),SEARCH(" ",RIGHT(A1,LEN(A1)-SEARCH("[",A1))),LEN(RIGHT(A1,LEN(A1)-SEARCH("[",A1)))-LEN(LEFT(RIGHT(A1,LEN(A1)-SEARCH("[",A1)),SEARCH(" ",RIGHT(A1,LEN(A1)-SEARCH("[",A1)))))))&" ["&LEFT(A1,SEARCH(" ",A1))&" and "&LEFT(MID(A1,SEARCH("[",A1)+1,999),SEARCH(" ",MID(A1,SEARCH("[",A1)+1,999))-1)&"]"
 
Upvote 0
No it doesn't. This works like a dream. Thanks a lot. I built half way but could not complete. Much appreciated.
 
Upvote 0
And another way :)

=SUBSTITUTE(TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),(3-1)*LEN(A1)+1,LEN(A1))),"]"," (")&SUBSTITUTE(TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),(2-1)*LEN(A1)+1,LEN(A1))),"[","")&" and "&TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),(1-1)*LEN(A1)+1,LEN(A1)))&")"
 
Upvote 0
This is using 84 less characters. Nice job. Thanks
This formula is a little bit shorter still (and, like admiral100's formula, it also does the bracket/parentheses swap as well)...

=SUBSTITUTE(SUBSTITUTE(MID(A1,FIND(" ",A1,FIND("[",A1))+1,99),"]"," ")&REPLACE(REPLACE(A1,FIND(" ",A1,FIND("[",A1))+1,0,"and "&LEFT(A1,FIND("[",A1)-2)&")"),1,FIND("[",A1),"("),MID(A1,FIND(" ",A1,FIND("[",A1))+1,99),"")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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