Excel format conversion

A

Aaron H

Hi guys, is there a way to convert the following
123456789 to 123-456-789
or
abcdefghi to abc-def-ghi
I need to convert a long list of serial numbers so I can look for them, but
doing it one by one will take me an eternity.

Thanks
 
E

Eduardo

Hi,
you can get the numbers but the text, a solution is to use text to columns
and then insert columns everyt three other
 
G

Gord Dibben

123456789 can be custom formatted 000-000-000

The letters not so easy.

You would need a helper column for that.

=LEFT(A1,3) & "-" & MID(A1,4,3) & "-" & RIGHT(A1,3)

Since the "numbers" are used as testual serial numbers you could skip the
custom format and use the same formula all the way down the list.


Gord Dibben MS Excel MVP

On Thu, 20 May 2010 10:23:01 -0700, Aaron H <Aaron
 
J

John

Hi Aaron
This works for numbers : =LEFT(A1,3)&-MID(A1,5,3)&-RIGHT(A1,3)
This one works for text and numbers, but your numbers are changed to text.
=LEFT(A2,3)&"-"&MID(A2,5,3)&"-"&RIGHT(A2,3)
HTH
John
 
A

Aaron H

Thanks Eduardo,
What I need is to add the dash every three caracters
Instead of 123456789 I need as a result 123-456-789
 
R

Rick Rothstein

=LEFT(A1,3) & "-" & MID(A1,4,3) & "-" & RIGHT(A1,3)

Or this slightly shorter alternate formula...

=REPLACE(REPLACE(A1,7,0,"-"),4,0,"-")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top