It appears that you want the characters that appear at the end of a string, to the right of the last instance of a hyphen character, "-"
.
This formula, adapted from here, works in Excel, *Calc & Google Sheets:
=TRIM(RIGHT(SUBSTITUTE(A1,"-",REPT(" ",LEN(A1))),LEN(A1)))
Explanation:
SUBSTITUTE(A1,"-",new_string)
will find each hyphen ("-"
) in the original string from cell A1
and replace it with a new_string
.
REPT(" ",LEN(A1))
is a string of repeated space characters (" "
), the same length as the original string in cell A1
.
TRIM(RIGHT(string,count))
will get the right-most count
characters, and trim off leading and trailing spaces. Since the string was previously padded out by replacing hyphens with spaces, and count
is the same LEN(A1)
used for that padding, the last count
characters consists of a bunch of spaces followed by whatever followed the last hyphen!
In Google Sheets, an alternative approach is to use the SPLIT function to break the value from column A into an array, then select the last element. (Excel-VBA has a split()
function, so you could make this work in Excel by writing VBA code to provide it as a custom function.)
=INDEX(SPLIT(A1,"-"),0,COUNTA(SPLIT(A1,"-")))