Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return fractional part of values
In an internal VBA calculation, I need to return the fractional part of a
value in a cell. For example, 5.35 returns 0.35 7.00 returns 0 I thought: dValue = ActiveCell.Value Mod 1 would do it, but this doesn't work...don't know why... Thanks much in advance for your assistance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return fractional part of values
<doesn't work What does that mean?
From Excel Help: The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) Try: Function test(a As Double) As Double test = a - Int(a) End Function Use "Fix" instead of "Int" depending on what you require; see VBA Help -- Kind regards, Niek Otten Microsoft MVP - Excel "XP" wrote in message ... | In an internal VBA calculation, I need to return the fractional part of a | value in a cell. | | For example, | | 5.35 returns 0.35 | | 7.00 returns 0 | | I thought: dValue = ActiveCell.Value Mod 1 | | would do it, but this doesn't work...don't know why... | | Thanks much in advance for your assistance. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return fractional part of values
Fraction = Activecell.Value - INT(Activecell.Value)
"XP" wrote: In an internal VBA calculation, I need to return the fractional part of a value in a cell. For example, 5.35 returns 0.35 7.00 returns 0 I thought: dValue = ActiveCell.Value Mod 1 would do it, but this doesn't work...don't know why... Thanks much in advance for your assistance. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return fractional part of values
don't know why...
The operative sentence in XL/VBA Help ("Mod"): The modulus, or remainder, operator divides number1 by number2 ***(rounding floating-point numbers to integers)*** Instead use With ActiveCell dValue = .Value - Fix(.Value) End With In article , XP wrote: In an internal VBA calculation, I need to return the fractional part of a value in a cell. For example, 5.35 returns 0.35 7.00 returns 0 I thought: dValue = ActiveCell.Value Mod 1 would do it, but this doesn't work...don't know why... Thanks much in advance for your assistance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formula to return part of a text string | Excel Discussion (Misc queries) | |||
can a function return part of it's result in italics? | Excel Worksheet Functions | |||
How do I isolate the Fractional part of a number in Excel VB? | Excel Programming | |||
return left most part of cell | Excel Worksheet Functions | |||
Help needed summing fractional values which have been rounded up | Excel Discussion (Misc queries) |