extract name after :

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,566
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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Thanks for the help. I am still trying to get to grips with Power Query. Are there any good tutorials or books you can recommend ?
 
Upvote 0
Sorry, the formula should reference A1 not L1.
TRIM(EXTRACTELEMENT(A1, 2, ":")

If I may make a comment here, as this is written, I believe you will get an error message because you have an uneven number of opening and closing parenthesis. It should be as follows:
Code:
[SIZE=5][COLOR=black][FONT=Calibri]=Trim(ExtractElement(A1,2,":")[/FONT][/COLOR][COLOR=#ff0000][FONT=Calibri])[/FONT][/COLOR]
[/SIZE]
I'd like to suggest another version of the same method of extracting the text following the ':'. I believe this will be easier to remember and less typing if this function is called many times in different places.

Code:
[SIZE=5][COLOR=black][FONT=Calibri]Function ExtractElement(txt, n, sep)[/FONT][/COLOR]
[/SIZE]
[SIZE=5][COLOR=black][FONT=Calibri]   ExtractElement = Trim(Split(Application.Trim(txt), sep)(n - 1))[/FONT][/COLOR][/SIZE]
[SIZE=5][COLOR=black][FONT=Calibri]End Function[/FONT][/COLOR][/SIZE]
Now place this in the cell and copy down as desired.

Code:
[SIZE=5][COLOR=black][FONT=Calibri]=ExtractElement(A1,2,":")[/FONT][/COLOR]
[/SIZE]

TotallyConfused
 
Last edited:
Upvote 0
Refering to my post #15 , I stand corrected. The function as it was originally written in posting #3 is correct, and does not need to be changed in any way. The formula that is placed in the cell does not need the 'TRIM' command. Enter it as:
Code:
[COLOR=black][FONT=Arial]=ExtractElement(A1,2,":")[/FONT][/COLOR]

I am sorry if my error has caused confusion for anyone.

TotallyConfused (yes, as you can see, I still am.)
 
Last edited:
Upvote 0
You're right about the parenthesis, I only had 1 closing but 2 opening so it would indeed generate an error, good spot! The additional trim in the VBA code is a nice touch too, I am most certainly not totallyconfused :D
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,896
Members
449,194
Latest member
JayEggleton

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