Thread: insert a dash
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_6_] Gary Brown[_6_] is offline
external usenet poster
 
Posts: 126
Default insert a dash

=if(len(a1)<=5,left(A1,1)&"-"&right(a1,len(a1)-1)
,left(a1,2)&"-"&right(a1,len(a1)-2))
--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Striker3070" wrote:

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

.