Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 --------------- Jacob Skaria "art" wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is another way to calculate intNew...
intNew = Left(intOld, (Len(intOld) - 3 + Abs(Len(intOld) - 3)) / 2) & _ Replace(Format(intOld, "!@@@"), " ", "0") -- Rick (MVP - Excel) "Jacob Skaria" wrote in message ... 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 --------------- Jacob Skaria "art" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Leading Zero's in Excel | Excel Discussion (Misc queries) | |||
Leading Zero's | Excel Discussion (Misc queries) | |||
How to get Leading Zero's passed | Excel Programming | |||
How to add leading zero's | Excel Worksheet Functions | |||
Leading zero's | Excel Discussion (Misc queries) |