Everything after Last 'X' Char

roland99

New Member
Joined
Jul 16, 2015
Messages
6
Hi I need to grab everything after the last "-" (strings can have up to four "-") and if there is a space after the last "-" to not take the space.
Please note that this formula is to work in SharePoint so some formulas may not work

Examples:
TEXT -(THIS VALUE)
TEXT - TEXT -(SPACE)(THIS VALUE)
TEXT - TEXT - TEXT -(THIS VALUE)
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Works great except how to I change it so that it grabs the String after the last "-" and not just the last Char?
Currently it returns just ")" I need it to return "(THIS VALUE)"
 
Upvote 0
Works great except how to I change it so that it grabs the String after the last "-" and not just the last Char?
Currently it returns just ")" I need it to return "(THIS VALUE)"
Mike had a typo... he had missed a closing parenthesis.

=TRIM(RIGHT(SUBSTITUTE(A1,"-",REPT(" ",255)),255))
 
Upvote 0
I'm not familiar with SharePoint.

SUBSITUTE(aString,findString,replaceString)

will replace every instance of findString in aString with replaceString.

Replace sounds like it might be SharePoint's equivalent of SUBSITUTE
(Exel's REPLACE is very different than SUBSTITUTE)

Also, REPT(" ",255) returns 255 spaces, I don't know if REPT has an equivalent in SharePoint.
 
Upvote 0
I'm not familiar with SharePoint.


Replace sounds like it might be SharePoint's equivalent of SUBSITUTE
(Exel's REPLACE is very different than SUBSTITUTE)

Replace() should work the same as it does in excel: REPLACE(old_text,start_num,num_chars,new_text)
Also its my understanding that Substitute essentially combines Search and Replace in a loop to find all instances of a string.

I came up with this:
=TRIM(REPLACE(TRIM((RIGHT(A1,FIND(" -",A1)-1))),1,0,""))

It not perfect as if there is no space after last "-" then it keeps the - as part of the string.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,629
Members
449,241
Latest member
NoniJ

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