Thread: insert a dash
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default insert a dash

And if you were looking for a VB solution, consider looping your cells using
a statement construction similar to this...

DashedText = Application.Replace(CellText, 3 + (LEN(CellText)=5),0,"-")

--
Rick (MVP - Excel)



"Rick Rothstein" wrote in message
...
Give this formula a try...

=REPLACE(A1,3-(LEN(A1)=5),0,"-")

--
Rick (MVP - Excel)



"Striker3070" wrote in message
...
I have a column of numbers, 5 digit up to 9 digit. I need to insert a
dash after the first number of any 5 digit number, and a dash after the
second digit if the number is longer than 5 digits.

so 12345 would need to become 1-2345
and 1234567 would need to become 12-34567

If my original numbers are in column A, I can make the new ones in Column
B