Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Rounding a Rounded Number

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Rounding a Rounded Number

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Rounding a Rounded Number

I get 7.29 as my result from using your information. Try to use the
RoundUp() function instead perhaps??

HTH
--
Regards,
Zack Barresse, aka firefytr



"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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Rounding a Rounded Number

Hi Zach,

If you put this code in a module, don't you get 7.28?

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

--
Ken Hudson


"Zack Barresse" wrote:

I get 7.29 as my result from using your information. Try to use the
RoundUp() function instead perhaps??

HTH
--
Regards,
Zack Barresse, aka firefytr



"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






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Rounding a Rounded Number

Hi Ken,

Dim your variables as Double, not Single

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"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


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number are rounded to thousand, but they now do not foot BGM Excel Discussion (Misc queries) 3 August 8th 06 07:24 PM
Can rounded numbers be summed without rounding errors? chelseab Excel Discussion (Misc queries) 1 February 8th 06 04:26 AM
Rounded-off number herve[_12_] Excel Programming 1 November 3rd 05 05:33 PM
marrying a rounded number to concatenation. Rodney New Users to Excel 2 October 1st 05 02:32 AM
showing a rounded number without rounding it svetlana Excel Programming 2 July 25th 03 05:45 PM


All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"