View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ken Hudson Ken Hudson is offline
external usenet poster
 
Posts: 186
Default Rounding a Rounded Number

Hi Charles,
I don't want to round everything up the next hundreth. For example, I want
to round 7.144 to 7.14 and 7.145 to 7.15. Ceiling doesn't look like the way
to get there.

OldRate = 27.11
NewRate = Application.WorksheetFunction.Round(OldRate * 1.075, 2)
NewRate = Application.WorksheetFunction.Round(NewRate * 0.25, 2)

If I put the above code in a VBA module, I get 7.28 and I want 7.29.

--
Ken Hudson


"Charles Chickering" wrote:

Use worksheetfunction.ceiling to round up. Round rounds to the nearest not up.
--
Charles Chickering

"A good example is twice the value of good advice."


"Ken Hudson" wrote:

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