How to TRIM characters to the LEFT of a special character?

binar

Board Regular
Joined
Aug 20, 2006
Messages
71
Fellow Forum Members,
The function below was posted by a member of this forum and it removes characters to the right of the last occurance of a special character:

=TRIM(LEFT(A1,FIND("$",SUBSTITUTE(A1,"|","$",LEN(SUBSTITUTE(A1,"|","%%"))-LEN(A1)))-1))

I would be very grateful if anyone out there can help me tweak this function so that it removes all characters to the LEFT of a special character (no last occurence needed since it only shows up one time). The special character in this case is an underscore "_"

For example:

xxxxxxx_13405050 converts to: _13405050
or
xrrkdkkwwppp_1230 converts to: _1230

Any help will be greatly appeciated. Thanks.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this
Code:
=IF(A1<>"",RIGHT(A1,LEN(A1)-FIND("_",A1)+1),"")

lenze
 
Last edited:
Upvote 0
Lenze and VOG,
Thank you very much for your prompt posts. Both formulas work perfectly. And they seem to be a lot less complicated than the one I was focused on tweaking. It makes one wonder when the TRIM function is the right tool for the job. Agan thanks for the help to solve this problem.
 
Upvote 0
The TRIM function is used to eliminate leading and trailing spaces. The part that actually truncates the function is the LEFT/MID/RIGHT formulas.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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