text format

kennethr

New Member
Joined
Jun 8, 2006
Messages
13
I have a list of text (part numbers) such as 704A34101006 which I want to re format with dashes included i.e 704A34-1010-06, is there a simple way to do this for a large number of cells at once, they are all in the format without the dashes and I want to keep the same digits but in the fornat with dashes

Any help would be much appreciatted
:(
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Jon von der Heyden

MrExcel MVP, Moderator
Joined
Apr 6, 2004
Messages
10,808
Office Version
  1. 365
Platform
  1. Windows
Assuming text lengths are always the same you could use:
=LEFT(A1,6)&"-"&MID(A1,7,4)&"-"&RIGHT(A1,2)
where A1 houses 704A34101006.

Regards,
Jon :)
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,424
Office Version
  1. 365
Platform
  1. Windows
Here is another one that only requires two function calls:
=REPLACE(REPLACE(A1,11,0,"-"),7,0,"-")
 

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
if your text is in cell C1 then the following formula will give you the desired result

c1 = 704A34101006

=CONCATENATE(LEFT(C1,6), "-",MID(C1,7,4),"-",RIGHT(C1,2))

formula output = 704A34-1010-06

ravi
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,424
Office Version
  1. 365
Platform
  1. Windows
if your text is in cell C1 then the following formula will give you the desired result

c1 = 704A34101006

=CONCATENATE(LEFT(C1,6), "-",MID(C1,7,4),"-",RIGHT(C1,2))

formula output = 704A34-1010-06

ravi
ravi

This suggestion certainly works but it is just the same as Jon's since CONCATENATE does just the same job as the '&' symbols in Jon's formula. This method still requires 4 functions whereas the REPLACE method only requires 2.
 

Forum statistics

Threads
1,136,369
Messages
5,675,362
Members
419,565
Latest member
Phil57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top