formula to insert zeros in front of numbers

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hello all,
I have in cells G9 the formula
Code:
 G9 = "0208888"&H9

So in H9 is a lookup formula. Then this is what I wanna do: When the number in H9 is one digit number , then place two zeros in front of it in the formula above. If two digits then place only one zeros in front of it.
Thanks in advance.
Kelly
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
The following assumes there will only be 1 or 2 digits in cell H9. If there are more, it treats it like there is 1 digit and adds one zero.

Code:
G9 ="0208888"&IF(LEN(H9)=2,"0"&H9,"00"&H9)
 
Upvote 0
If the 020888 is fixed and never changing, then this will work...

=TEXT(H9,"\02\0888000")
 
Upvote 0
Code:
G9 ="0208888"&IF(LEN(H9)=2,"0"&H9,"00"&H9)

Okay thanks very much. I have added a third argument to take care of my need.
Code:
G9 ="0208888"&IF(LEN(H9)=3,H9,IF(LEN(H9)=2,"0"&H9,"00"&H9))
 
Upvote 0
Oh okay this one too is simple and cool yet it shows only three of the 8s instead of four. Regards.
Kelly
I took the number of 8's from Eric's post (it was his formula that gave me the idea for mine). Anyway, the fix is quite simple... just put another 8 into the text...

=TEXT(H9,"\02\08888000")
 
Last edited:
Upvote 0
I took the number of 8's from Eric's post (it was his formula that gave me the idea for mine). Anyway, the fix is quite simple... just put another 8 into the text...

=TEXT(H9,"\02\08888000")

Sure the fix was simple. I also got confused because of Eric's post. But was able to resolve it later. My network was down so I was not able to post it back. Thanks again.
Kelly
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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