Extract and Repost Names

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
304
Office Version
  1. 2016
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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,216,058
Messages
6,128,538
Members
449,456
Latest member
SammMcCandless

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