Remove text from name

sobrien1234

Board Regular
Joined
May 10, 2016
Messages
175
Office Version
  1. 365
Platform
  1. Windows
I have a list of names however some of them have text in the middle which i want removed. In column J I have the following names - I want to write a formula in column K that removes the text in between [ ] so it just shows their name - for example, in the 2nd row the answer would be "Grant Matthew" if the formula works. Thanks in advance!!
Radoslovic Stephen
Grant [MY-GRANT01] Matthew
Tait [MY-TAIT01] John
Virgo [MY-VIRGO01] Tamara
Tait [MY-TAIT01] John
Mezger - OLD ACC Kelly
Ruig Joel
Radoslovic Stephen
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Is it safe to assume first and last words are always what you want?
 
Upvote 0
Does this formula do what you want...

=IFERROR(REPLACE(J1,FIND("[",J1)-1,FIND("]",J1)-FIND("[",J1)+2,""),J1)
 
Upvote 0
with Power Query based on your example

name.png

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TAD = Table.AddColumn(Source, "Text After Delimiter", each Text.AfterDelimiter([Name], " ", {0, RelativePosition.FromEnd}), type text),
    TBD = Table.AddColumn(TAD, "Text Before Delimiter", each Text.BeforeDelimiter([Name], " "), type text),
    Merge = Table.CombineColumns(TBD,{"Text Before Delimiter", "Text After Delimiter"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Names"),
    ROC = Table.SelectColumns(Merge,{"Names"})
in
    ROC
 
Upvote 0
Does Rick's formula work on the items without brackets?
Here's another option, though huge and clumsy.
=LEFT(J1,FIND(" ",J1,1)-1)&" "&MID(J1,FIND(">",SUBSTITUTE(J1," ",">",LEN(J1)-LEN(SUBSTITUTE(J1," ",""))))+1,LEN(J1)-FIND(">",SUBSTITUTE(J1," ",">",LEN(J1)-LEN(SUBSTITUTE(J1," ","")))))
Try them each on line 5 for example.
 
Upvote 0
What I was unclear in is whether the "- OLD ACC" part in line 6 needed to be removed even though it was not enclosed in brackets. Either way, there are 2 options.

Thanks for all you do Rick. I believe you were the first to help me years ago when I first got on this message board.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

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