UPC format-text with dashes and possible leading zero

XL Rookie

Board Regular
Joined
Apr 9, 2009
Messages
57
12 digits, may or may not have a leading zero. Needs dashes as follow: 0-12345-67890-1

client inputs the numbers. Leading number may or may not have a zero but if it does, it needs to be visible.

I was trying to do text but with dashes as a customer but couldn't quite get there.

thanks!
Kimberly
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try custom format of:
0-00000-00000-0
 
Upvote 0
You are welcome.

It is important to know that Cell Formats only work on Numeric entries (don't work on Text entries).
That means that the entries really are numeric, meaning that the leading zero really isn't there (it is just formatted to look that way).
It is important to know that, because it could lead to confusion if you don't understand how it works.

For example, let's say that you have your 0-12345-67890-1 entry in cell A1.
Do you want to take a guess what this formula might return?
=LEFT(A1,3)
It will return "123" (not "0-1" or even "012").
That is because your entry is really 12345678901 with a Custom Format.

If you wanted to return the value with the leading zeroes and dashes to use for other purpose, you can use the TEXT function (which converts it to Text with that Custom format), i.e.
=TEXT(A1,"0-00000-00000-0")
 
Last edited:
Upvote 0
Thanks for the explanation. Again, I may be trying to overthink a problem that doesn't exist. Time will tell.

Kimberly
 
Upvote 0
The Custom Format will work fine.
I just wanted to make you aware of the other stuff in case you try doing anything with that value, and gets unexpected results.
 
Upvote 0
The Custom Format will work fine.
I just wanted to make you aware of the other stuff in case you try doing anything with that value, and gets unexpected results.

Thanks for being a great resource and a thorough teacher!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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