Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 21
Smile VBA Rounding

I am trying to see if the VBA rounding function will round to even. As an example:

Cell A1:A6
2.45
2.75
2.89
2.67
2.56
2.32

Result from above
2.4
2.8
2.8
2.6
2.6
2.4

I cannot find anything online that will accomplish this. Does anyone know the code in VBA that may work?

Thank you

Gene Haines
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default VBA Rounding

Looks like you want a sort of bankers' rounding but to a 1 place decimal

One way, but warning only lightly tested with your example data

arr = Array(2.45, 2.75, 2.89, 2.67, 2.56, 2.32)

For i = 0 To UBound(arr)
Debug.Print arr(i), Int((arr(i) * 10 + Int(arr(i) * 10) Mod 2)) / 10
Next

2.45 2.4
2.75 2.8
2.89 2.8
2.67 2.6
2.56 2.6
2.32 2.4

Curiosity, what's the purpose for such rounding?

Regards,
Peter T


"Gene Haines" wrote in message
...

I am trying to see if the VBA rounding function will round to even. As
an example:

Cell A1:A6
2.45
2.75
2.89
2.67
2.56
2.32

Result from above
2.4
2.8
2.8
2.6
2.6
2.4

I cannot find anything online that will accomplish this. Does anyone
know the code in VBA that may work?

Thank you

Gene Haines



  #3   Report Post  
Junior Member
 
Posts: 21
Default

Quote:
Originally Posted by Gene Haines View Post
I am trying to see if the VBA rounding function will round to even. As an example:

Cell A1:A6
2.45
2.75
2.89
2.67
2.56
2.32

Result from above
2.4
2.8
2.8
2.6
2.6
2.4

I cannot find anything online that will accomplish this. Does anyone know the code in VBA that may work?

Thank you

Gene Haines
Peter: Guy in work is a metallurgist and is using this type of rounding for chemical composition. He had asked me if I knew a way to do this. Of course I volunteered to help him out.

Thanks for your response

Gene
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default VBA Rounding

Gene Haines wrote:
Gene Haines;1621934 Wrote:
I am trying to see if the VBA rounding function will round to even. As
an example:

Cell A1:A6
2.45
2.75
2.89
2.67
2.56
2.32

Result from above
2.4
2.8
2.8
2.6
2.6
2.4

I cannot find anything online that will accomplish this. Does anyone
know the code in VBA that may work?

Thank you

Gene Haines


Peter: Guy in work is a metallurgist and is using this type of rounding
for chemical composition. He had asked me if I knew a way to do this. Of
course I volunteered to help him out.

Thanks for your response

Gene




why not


=MROUND(A1,0.2)

?


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 07:41 PM
Rounding Russ_Hiatt Excel Discussion (Misc queries) 2 February 17th 09 07:13 PM
Rounding up or down Taylor Excel Discussion (Misc queries) 4 April 17th 08 03:51 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
Worksheet rounding vs VBA rounding Simon Cleal Excel Programming 4 September 2nd 05 01:50 AM


All times are GMT +1. The time now is 06:01 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"