Insert leading zero's

  • Thread starter Thread starter art
  • Start date Start date
A

art

Hello:

I would like to use a code that will do the following:

If I enter in Range(ABC...) 1 or 2 digits, then it should be followed with
two zero's, and if its more than 2 digits then leave it as is. So if I enter
4, it should turn it to 400 and if I enter 435 it should leave it like that.

Thanks so Much.

Art
 
Somthing like the below

Dim intOld as Integer, intNew As Integer

intOld = 43
intNew = IIf(intOld < 100, intOld * 10 ^ (3 - Len(intOld)), intOld)

If this post helps click Yes
 
Here is another way to calculate intNew...

intNew = Left(intOld, (Len(intOld) - 3 + Abs(Len(intOld) - 3)) / 2) & _
Replace(Format(intOld, "!@@@"), " ", "0")
 
Back
Top