Thread: Remove dash(s)
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gary''s Student
 
Posts: n/a
Default Remove dash(s)

=SUBSTITUTE(LEFT(A1,LEN(A1)-2),"-","") & RIGHT(A1,2)

The will preserve the last dash if it is followed by a single digit.
--
Gary's Student


"Pierre" wrote:

Maybe someone here could provide guidance:

Have a column containing data which may have 1-3 dashes locates within
each cell value.
Such as:
125-457A
158-857-1116
124184A-1
125-8745-22D9
458-2145-002-7


Would like to remove all the dashes "unless" the last dash to the right
is followed by a just a single digit. The results would be as follows:
125457A
1588571116
124184A-1
125874522D9
4582145002-7

On the example data, it kept 2 of the dashes in the cell values,
because the were only one digit away from the extreme right, but
removed all others.

TIA for any thoughts.

Pierre