Andreamary
asked on
Trim formula based on first dash in text string
Column A has the following formats:
A1: XXXX-XX
A2: XXXX
A3: XXXX-XX-XXX
A4: XXXX-XX-X
I need a formula in Column B that trims Column A after the first dash, so the results of the above rows would be:
B1: XX
B2:
B3: XXX
B4: X
I have been using the following formula to date, which worked as there was always just one dash in the text string, but now that there can be more than one dash, I am not getting the results I need:
=TRIM(RIGHT(SUBSTITUTE(A1, "-",REPT(" ",LEN(A1))),LEN(A1)))
I have attached a sample file. Column C shows the desired results.
Thanks!
Andrea
Trim-EE.xlsx
A1: XXXX-XX
A2: XXXX
A3: XXXX-XX-XXX
A4: XXXX-XX-X
I need a formula in Column B that trims Column A after the first dash, so the results of the above rows would be:
B1: XX
B2:
B3: XXX
B4: X
I have been using the following formula to date, which worked as there was always just one dash in the text string, but now that there can be more than one dash, I am not getting the results I need:
=TRIM(RIGHT(SUBSTITUTE(A1,
I have attached a sample file. Column C shows the desired results.
Thanks!
Andrea
Trim-EE.xlsx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers,
Andrea