M
Mark Dev
All,
Windows XP, Excel 2000
I have noticed that when my VBA code writes a variable (of Currency data
type) out to a worksheet, the cell automatically truncates or rounds it to
two decimal places, even though the currency variable contains a value with
4 decimal places.
This can be duplicated by creating a simple VBA subroutine behind a clean
worksheet (i.e. no formatting at all):
Public Sub TestItOut()
Dim curMyValue as Currency
Dim dblMyValue as Double
curMyValue = 548126789.4482
dblMyValue = 548126789.4482
Range("A1").Value = curMyValue
Range("B1").Value = dblMyValue
End Sub
A1 will contain 548126789.45, and B1 will contain 548126789.4482.
Does anyone know the rule that governs this automatic formatting? Is the
value always truncated? Is it rounded? Is there any way to stop it from
doing this, or control it?
Thanks,
Mark D.
Windows XP, Excel 2000
I have noticed that when my VBA code writes a variable (of Currency data
type) out to a worksheet, the cell automatically truncates or rounds it to
two decimal places, even though the currency variable contains a value with
4 decimal places.
This can be duplicated by creating a simple VBA subroutine behind a clean
worksheet (i.e. no formatting at all):
Public Sub TestItOut()
Dim curMyValue as Currency
Dim dblMyValue as Double
curMyValue = 548126789.4482
dblMyValue = 548126789.4482
Range("A1").Value = curMyValue
Range("B1").Value = dblMyValue
End Sub
A1 will contain 548126789.45, and B1 will contain 548126789.4482.
Does anyone know the rule that governs this automatic formatting? Is the
value always truncated? Is it rounded? Is there any way to stop it from
doing this, or control it?
Thanks,
Mark D.