Increase number of digits

Philatelist

New Member
Joined
Jan 24, 2023
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
Hi, I have a random number of digits, could be between 1 and 6, possibly containing a prefix letter, but I need the numeric string to be 12 digits long. How can I add the correct number of leading 0's to make 12?

So for instance in cell A1 I have the number T777, I need cell B1 to read 000000000777.

In Cell A2 I have 1234, I need B2 to read 000000001234

Thanks in advance, I'm sure one of you guys can solve in minutes!

A~
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
How about
Excel Formula:
=TEXT(IF(ISERROR(LEFT(A2)+0),MID(A2,2,100),A2)+0,REPT(0,12))
 
Upvote 0
if only there is one prefix letter:
mr excel questions 24.xlsm
AB
1T777000000000777
21234000000001234
Philatelist
Cell Formulas
RangeFormula
B1:B2B1=TEXT(IF(ISNUMBER(1*LEFT(A1,1))=FALSE,RIGHT(A1,LEN(A1)-1),A1),"000000000000")
 
Upvote 0
Fantastic response thanks, Arthurbr, your solution doesn't seem to take into account the possible Prefix letter, Fluff and Awoohaw, both solutions worked perfectly.
Dare I follow up though with a basic beginners question? If A1 is empty, what is the simplest method of making B1 appear empty also instead of #VALUE!
Thanks again
 
Upvote 0
How about
Excel Formula:
=IF(A2="","",TEXT(IF(ISERROR(LEFT(A2)+0),MID(A2,2,100),A2)+0,REPT(0,12)))
 
Upvote 0
Solution
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,989
Messages
6,122,622
Members
449,093
Latest member
catterz66

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