rcrecelius
Technical User
thread68-907911
Back in 2004 I asked this question and KenWright gave me a formula that has saved me countless hours of frustration...so let me starrt by saying thanks again Ken!
Now today, I am realizing that this formula does have a shortfall. Here is my original question from 2004
I have part numbers which may have a combination of letters, dashes, and numbers. I have to go thru and manually delete the dashes from some part numbers but not all of them.
This is the desired "format"...
If the dash is between a letter and a number - delete it.
If the dash is between 2 numbers or 2 letters - keep it.
"Good examples" - keep the dash
A10-1
204-166
735-10
2035E-S
"Bad examples" - delete the dash
A-10
2035-ES
Ken provided me this formula which works as advertised on the above examples and I have used it a LOT.
=IF((ISNUMBER(--MID(A1,FIND("-",A1)-1,1))*ISNUMBER(--MID(A1,FIND("-",A1)+1,1))+NOT(ISNUMBER(--MID(A1,FIND("-",A1)-1,1)))*NOT(ISNUMBER(--MID(A1,FIND("-",A1)+1,1)))),A1,SUBSTITUTE(A1,"-","",1))
Now...I am finding that I have multiple instances of the dash that need to be considered for removal...the above formula is only looking at the first dash.
EX: CB2.5L-C-1 Desired output CB2.5L-C1
The dash between the C and 1 needs to be removed but I think the formula is only addressing the first dash it finds, which in this case does not need to be deleted.
Is there anything that can be done to enhance this formula so that it will look at multiple dashes within the same cell?
Back in 2004 I asked this question and KenWright gave me a formula that has saved me countless hours of frustration...so let me starrt by saying thanks again Ken!
Now today, I am realizing that this formula does have a shortfall. Here is my original question from 2004
I have part numbers which may have a combination of letters, dashes, and numbers. I have to go thru and manually delete the dashes from some part numbers but not all of them.
This is the desired "format"...
If the dash is between a letter and a number - delete it.
If the dash is between 2 numbers or 2 letters - keep it.
"Good examples" - keep the dash
A10-1
204-166
735-10
2035E-S
"Bad examples" - delete the dash
A-10
2035-ES
Ken provided me this formula which works as advertised on the above examples and I have used it a LOT.
=IF((ISNUMBER(--MID(A1,FIND("-",A1)-1,1))*ISNUMBER(--MID(A1,FIND("-",A1)+1,1))+NOT(ISNUMBER(--MID(A1,FIND("-",A1)-1,1)))*NOT(ISNUMBER(--MID(A1,FIND("-",A1)+1,1)))),A1,SUBSTITUTE(A1,"-","",1))
Now...I am finding that I have multiple instances of the dash that need to be considered for removal...the above formula is only looking at the first dash.
EX: CB2.5L-C-1 Desired output CB2.5L-C1
The dash between the C and 1 needs to be removed but I think the formula is only addressing the first dash it finds, which in this case does not need to be deleted.
Is there anything that can be done to enhance this formula so that it will look at multiple dashes within the same cell?