To simply combine them you can place them all together like this:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"_AB","_"),"_CD","_"),"_EF","_"),"_40K",""),"_60K",""),"_S_","_"),"_","-")
(note that this may pass the older Excel limit of 7 nested statements. I'm testing in Excel 2010
Another way to do it is by utilizing Left and Right functions.
This assumes that the changing data on the end is always present and is 8 characters long
=SUBSTITUTE(LEFT(A2,LEN(A2)-8),"_","-")
This will achieve the same resulting string
If the string doesn't always end with 8 characters that you want to strip off you can search for the "_S" and get the current location. Try this:
=SUBSTITUTE(LEFT(A2,FIND("_S",A2,1)),"_","-")
Answer from Automate This on Stack OverflowTo simply combine them you can place them all together like this:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"_AB","_"),"_CD","_"),"_EF","_"),"_40K",""),"_60K",""),"_S_","_"),"_","-")
(note that this may pass the older Excel limit of 7 nested statements. I'm testing in Excel 2010
Another way to do it is by utilizing Left and Right functions.
This assumes that the changing data on the end is always present and is 8 characters long
=SUBSTITUTE(LEFT(A2,LEN(A2)-8),"_","-")
This will achieve the same resulting string
If the string doesn't always end with 8 characters that you want to strip off you can search for the "_S" and get the current location. Try this:
=SUBSTITUTE(LEFT(A2,FIND("_S",A2,1)),"_","-")
No need to use VBA anymore for this! Super simple formula now!
=REDUCE(A1,2:
6,LAMBDA(a,b,SUBSTITUTE(a,b,OFFSET(b,0,1))))
Where A1 is the target cell to replace text b2:b6 is where the keywords are stored (texts to be replaced) c2:c6 (referenced by the offset) is where the replacing texts are stored
Credit: Chandoo
in cell b1: =SUBSTITUTE(A1,"--","-")
you can then copy this across to c1, d1, e1 etc. Each further cell to the right will have one less - than the previous. Add columns until all hyphens are dealt with.
This way if you add a new row where there are more hyphens than in previous rows, you can just make extra columns, instead of changing the formula which gets messy.
A tiny trick for a single cell solution. If A1 does not contain any spaces, in A2 enter:
=SUBSTITUTE(TRIM(SUBSTITUTE(A1,"-"," "))," ","-")
This can handle any number of consecutive dashes:

If A1 does contain some spaces, a slightly more complex formula will be required!
EDIT#1:
If A1 contains spaces, they must first be "protected" with something like:
=SUBSTITUTE(A1," ",CHAR(1))
and then, in the outer-most substitution, the "protection" must be removed. The final formula is:
=SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(A1," ",CHAR(1)),"-"," "))," ","-"),CHAR(1)," ")
I will admit that this is pretty ugly, but it can handle an unlimited number of dashes.
Multiple SUBSTITUTE Functions
Using substitute to remove multiple characters at the same time
VBA Excel substitute function for multiple conditions at once - Code Review Stack Exchange
SUBSTITUTE formula using two arrays for readability instead of multiple nested SUBSTITUTEs, iterated only once per input
I want to use substitute with {".","!",";"} etc to remove the common non-alphanumeric characters. I know I can nest a bunch of substitute formulas together, but is there a way to do this by passing an array of symbols into the formula instead?