Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I isolate the Fractional part of a number in Excel VB?
I'm a novice writing a VB program in Excel 2003, and I need to isolate the fractional part of a number. In other words... Input: 23.0891467 Output: 0.0891467 The only way I know of to do this is (Result = Input Mod 1). The problem, is that while the Mod Operator works as a Worksheet Function - when used as a VB Operator, Excel truncates the fractional portion of the result. This, of course, makes it useless to me. I need to know the best way to isolate the fractional portion of a number (with maximum precision), that will work in Excel VB. Any help will be appreciated! Thanks! :) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I isolate the Fractional part of a number in Excel VB?
Dim Num as double
num = 23.0891467 num = num - int(num) Is one way. Cumulous wrote: I'm a novice writing a VB program in Excel 2003, and I need to isolate the fractional part of a number. In other words... Input: 23.0891467 Output: 0.0891467 The only way I know of to do this is (Result = Input Mod 1). The problem, is that while the Mod Operator works as a Worksheet Function - when used as a VB Operator, Excel truncates the fractional portion of the result. This, of course, makes it useless to me. I need to know the best way to isolate the fractional portion of a number (with maximum precision), that will work in Excel VB. Any help will be appreciated! Thanks! :) -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I isolate the Fractional part of a number in Excel VB?
Dim input as double, output as double
Output=Input-int(Input) Sub GetFraction() Dim x As Double, y As Double x = 23.0891467 y = x - Int(x) Debug.Print y End Sub y=8.91467000000006E-02 "Cumulous" wrote: I'm a novice writing a VB program in Excel 2003, and I need to isolate the fractional part of a number. In other words... Input: 23.0891467 Output: 0.0891467 The only way I know of to do this is (Result = Input Mod 1). The problem, is that while the Mod Operator works as a Worksheet Function - when used as a VB Operator, Excel truncates the fractional portion of the result. This, of course, makes it useless to me. I need to know the best way to isolate the fractional portion of a number (with maximum precision), that will work in Excel VB. Any help will be appreciated! Thanks! :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
isolate a number in cell with text and numbers | Excel Discussion (Misc queries) | |||
Removing part of a number in Excel | Excel Discussion (Misc queries) | |||
excel data label format special number characters (part 2) | Excel Discussion (Misc queries) | |||
Isolate rows based on highlight (Excel 2003) | Excel Worksheet Functions | |||
Need Excel to read a text field(part#) and assign a number(commiss | Excel Programming |