extract name after :

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have tried to set up a formula to extract the name to the right of : . in this instance I want Barnaby extracted

I can get it to work, but if the name changes, I have to amend my formula



Your assistance is most appreciated



Book1
ABCDEFGHIJKLM
1Enterprise name: BarnabyBarnaby
Sheet1
Cell Formulas
RangeFormula
L1=RIGHT(A1,SEARCH(":",A1)-8)
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
try

=TRIM(RIGHT(SUBSTITUTE(A1,":",REPT(" ",500)),500))

or

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",500)),500))
 
Upvote 0
If the format is always "Enterprise name: Person_Name"
Then you can setup a function in the VBA to split a string based on a specified delimiter.

So in this case you can split based on the colon :)) and take the element after the colon, nesting with a TRIM function to get rid of the whitespace.

Try this in a VBA module within your workbook,
Function EXTRACTELEMENT(txt, n, sep)
EXTRACTELEMENT = Split(Application.Trim(txt), sep)(n-1)
End Function

Then in cell L1 enter the formula as follows:
TRIM(EXTRACTELEMENT(L1, 2, ":")
The result will be "Barnaby"

This should work when dragged down the L column with all other names given a consistent format as followed.

I got the EXTRACTELEMENT function from the VBA book for dummies - handy book! Credit to them for the function.
 
Upvote 0
Sorry, the formula should reference A1 not L1.
TRIM(EXTRACTELEMENT(A1, 2, ":")
 
Upvote 0
Hi,

You can get it to work with the RIGHT function, but would be easier with MID:


Book1
ABC
1Enterprise name: BarnabyBarnabyBarnaby
Sheet612
Cell Formulas
RangeFormula
B1=TRIM(MID(A1,FIND(":",A1)+1,99))
C1=TRIM(RIGHT(A1,LEN(A1)-FIND(":",A1)))
 
Upvote 0
also you can try PowerQuery

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table7"]}[Content],
    #"Extracted Text After Delimiter" = Table.TransformColumns(Source, {{"Column1", each Text.AfterDelimiter(_, ": "), type text}})
in
    #"Extracted Text After Delimiter"[/SIZE]

Column1Column1
Enterprise name: BarnabyBarnaby
 
Upvote 0

Forum statistics

Threads
1,214,896
Messages
6,122,132
Members
449,066
Latest member
Andyg666

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