Custom formatting 19-21 character long string with leading 0s

aunakhtar

New Member
Joined
Mar 16, 2018
Messages
1
Hi,

Our accounts numbers look like this: 0034-43070-3000-260-561-99

I am creating an excel file where the user, ideally, would want to type in the above account number without hyphens into a cell and then the formatting should automatically insert the hyphens.

Problem(s) I ran into are that if I convert the above string to number for custom format, Excel ignores anything beyond 15 digits and changes that to 0.
If I convert to text, then I cannot use custom format. I tried coming up with a formula but the leading 0s after each hyphen are making the formula very complicated (I am using the Left+Text functions).

Is there any simple way that the user either enters 3443070300026056199 or 003443070300026056199 and it converts to the required format?

Thanks in advance.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi,

A formula solution would be like this:


Book1
ABC
10034430703000260561990034-43070-3000-260-500-00
234430703000260561990034-43070-3000-260-500-00
Sheet30
Cell Formulas
RangeFormula
C1=TEXT(A1,"0000-00000-0000-000-000-00")
 
Upvote 0
Also, alternatively, if you want to Format the cell so that it'll show as 0034-43070-3000-260-500-00 when either 003443070300026056199 or 3443070300026056199 is entered into the subject cell, use this as your Custom format for the Subject cells:

0000-00000-0000-000-000-00
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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