Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Rounding Based on Value

We prepare conceptual cost estimates for architectural
clients, and frequently do unit cost math in a cell. I
would like to program a macro to round the calculated
value appropriate to its value, e.g.:

<$1 Nearest penny $.51
<$10 Nearest dollar $9.00
<$100 Nearest ten $90.00
$1000 TBD


I've programmed in Access but have only used the Macro
recorder in Excel. Can someone tell me how to construct
an appropriate Switch statement?

Kevin Sprinkel

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Rounding Based on Value

Kevin,

Something like

If myvalue < 1 Then
myvalue = Round(myvalue, 2)
ElseIf myvalue < 10 Then
myvalue = Round(myvalue, 0)
ElseIf myvalue < 100 Then
myvalue = Round(myvalue / 10, 0) * 10
Else
'TBD
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Kevin Sprinkel" wrote in message
...
We prepare conceptual cost estimates for architectural
clients, and frequently do unit cost math in a cell. I
would like to program a macro to round the calculated
value appropriate to its value, e.g.:

<$1 Nearest penny $.51
<$10 Nearest dollar $9.00
<$100 Nearest ten $90.00
$1000 TBD


I've programmed in Access but have only used the Macro
recorder in Excel. Can someone tell me how to construct
an appropriate Switch statement?

Kevin Sprinkel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Rounding Based on Value

Thanks, Bob.

-----Original Message-----
Kevin,

Something like

If myvalue < 1 Then
myvalue = Round(myvalue, 2)
ElseIf myvalue < 10 Then
myvalue = Round(myvalue, 0)
ElseIf myvalue < 100 Then
myvalue = Round(myvalue / 10, 0) * 10
Else
'TBD
End If

--

HTH

Bob Phillips


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Rounding Based on Value

http://groups.google.com/groups?selm...08%40erols.com

gives a formula for rounding to a specified number of significant figures.

Jerry

Kevin Sprinkel wrote:

We prepare conceptual cost estimates for architectural
clients, and frequently do unit cost math in a cell. I
would like to program a macro to round the calculated
value appropriate to its value, e.g.:

<$1 Nearest penny $.51
<$10 Nearest dollar $9.00
<$100 Nearest ten $90.00

$1000 TBD


I've programmed in Access but have only used the Macro
recorder in Excel. Can someone tell me how to construct
an appropriate Switch statement?

Kevin Sprinkel


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
ROUNDING FORMULA =ROUND(B12/$B$10,1) ROUNDING TO HIGH SunshineinFt.Myers[_2_] Excel Worksheet Functions 7 March 5th 09 06:41 PM
Payouts based on hours and rounding down if hour is not in list. The_Sleeper Excel Worksheet Functions 2 July 24th 07 01:09 PM
I need a formula with rounding up & rounding down to the nearest . Tony Kay Excel Worksheet Functions 3 May 29th 07 11:13 PM
Significant number rounding based on key cell Slashman Excel Worksheet Functions 2 August 27th 06 11:04 PM
Rounding up for down based on cell value Allison Excel Worksheet Functions 3 February 8th 05 10:10 PM


All times are GMT +1. The time now is 06:14 PM.

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

About Us

"It's about Microsoft Excel"