Re: Rounding a Rounded Number
- From: Ken Hudson <KenHudson@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Dec 2006 09:21:01 -0800
Hi Don,
I'm not sure the one-liner would give the result I needed.
The calculation is payroll related and I need to round the first reponse
before multiplying again.
If I get three decimals in the first calculation and multiply that by
another number without having rounded the first answer, wouldn't I get a
different answer than if I had rounded the first calculation?
For example, if I get 1.549 in the first calcuation and multiply by 1.1,
then: 1.549 * 1.1 = 1.7039 rounded to 1.70
If I round the 1.549 to 1.55, then: 1.55 * 1.1 = 1.705 rounded to 1.71
--
Ken Hudson
"Don Guillett" wrote:
You didn't like the one liner..
sub oneliner()
MsgBox Round(Range("a1") * 1.075 * 0.25, 2)
end sub
--
Don Guillett
SalesAid Software
dguillett1@xxxxxxxxxxxxx
"Ken Hudson" <KenHudson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DA497D9C-5900-427F-BADD-1B6AD3323C0E@xxxxxxxxxxxxxxxx
Nick,
That was it - the variable needed to be double precision - although I
don't
know why.
Thanks for the early Christmas present!
Warmest regards....
--
Ken Hudson
"Niek Otten" wrote:
Hi Ken,
Dim your variables as Double, not Single
--
Kind regards,
Niek Otten
Microsoft MVP - Excel
"Ken Hudson" <KenHudson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ABE68F2D-BF85-49C1-AA30-5034340EBD32@xxxxxxxxxxxxxxxx
| 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(OldRate * 1.075, 2)
|
| Then I need to multiply that rounded result by .25 and round it up to
two
| decimal places.
| AdjustedNewRate=Application.Worksheetfunction.Round(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
- Follow-Ups:
- Re: Rounding a Rounded Number
- From: Don Guillett
- Re: Rounding a Rounded Number
- References:
- Re: Rounding a Rounded Number
- From: Niek Otten
- Re: Rounding a Rounded Number
- From: Don Guillett
- Re: Rounding a Rounded Number
- Prev by Date: Re: Finding Cell Address from Listbox
- Next by Date: RE: VBA to -0- an amount during a Copy/Paste of a range of cells
- Previous by thread: Re: Rounding a Rounded Number
- Next by thread: Re: Rounding a Rounded Number
- Index(es):