Rounding a Rounded Number
this gives me 7.29
Option Explicit
Dim newrate As Double, oldrate As Double
Sub test()
oldrate = 27.11
newrate = _
Application.WorksheetFunction.Round(Application.Wo rksheetFunction.Round(oldrate
_
* 1.075, 2) * 0.25, 2)
Debug.Print newrate
End Sub
--
Gary
"Ken Hudson" wrote in message
...
I'm working in Excel 2003 - VBA.
OldRate is a variable whose value comes from user input into a cell.
OldRate=Range("A1")
I am multiplying that variable by 1.075 and need to round up the result to
two decimal places.
NewRate=Application.Worksheetfunction.Round(OldRat e * 1.075, 2)
Then I need to multiply that rounded result by .25 and round it up to two
decimal places.
AdjustedNewRate=Application.Worksheetfunction.Roun d(NewRate * .25, 2)
If $27.11 is the old rate, I would expect that $27.11 * 1.075 = $29.14
(rounded).
And $29.14 * .25 = $7.29 (rounded).
However, I am getting $7.28 in VBA.
How do I get VBA to give me $7.29?
TIA.
--
Ken Hudson
|