Adding a dash after the first five digits (for a ten digit number), and after the first five and ten digits (for a twelve digit number)

Kibz Wahid

New Member
Joined
Mar 6, 2017
Messages
3
[h=2]Hello all, I have a list containing alpha-numeric part numbers, some are 10 in number others 12.

My problem is how to insert a dash after the first five digits (where the part number has 10 digits) eg. 0446460340 to 04465-60340; and inserting a dash after the first five and ten digits (where the part number has 12 digits) eg. 99364-00850-8S

Thanks![/h]

<colgroup><col width="92"></colgroup><tbody>
</tbody>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Welcome to the Board!

Are you talking about a Custom Format, or you actually want the dashes physically inserted?
Do you want it to replace the current entry, or are you looking for a formula to put in another cell?
 
Upvote 0
Try. I am assuming that all Part numbers are ether 10 digits or12 digits. If any are a different length then this will not work.
Code:
=IF(LEN(A1)=10,LEFT(A1,5)&"-"&MID(A1,6,5),LEFT(A1,5)&"-"&MID(A1,6,5)&"-"&RIGHT(A1,2))
 
Upvote 0
If you want a formula
=TEXT(D1, "[<10000000000]00000-00000;00000-00000-00")

or you could use the format string in a custom number format.
 
Upvote 0
Welcome to the Board!

Are you talking about a Custom Format, or you actually want the dashes physically inserted?
Do you want it to replace the current entry, or are you looking for a formula to put in another cell?

Hello, yes - was thinking of a custom format. Have just seen Scott T's input; worked like a charm!

Thanks for the quick and friendly response!
 
Upvote 0
Hello, yes - was thinking of a custom format. Have just seen Scott T's input; worked like a charm!
If you were thinking of a custom format, then you should read Message #4 which tells you how to do it.
 
Upvote 0
If you want a formula
=TEXT(D1, "[<10000000000]00000-00000;00000-00000-00")

or you could use the format string in a custom number format.

I've tried the formula, works fine for a ten digit number; but cannot seem to get it to work on the 12 digits.
 
Upvote 0

Forum statistics

Threads
1,215,206
Messages
6,123,638
Members
449,109
Latest member
Sebas8956

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
Back
Top