Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.excel.programming > #107996 > unrolled thread
| Started by | Gene Haines <Gene.Haines.1023e9c8@excelbanter.com> |
|---|---|
| First post | 2015-08-26 22:29 +0100 |
| Last post | 2015-08-27 20:49 -0500 |
| Articles | 4 — 4 participants |
Back to article view | Back to microsoft.public.excel.programming
VBA Rounding Gene Haines <Gene.Haines.1023e9c8@excelbanter.com> - 2015-08-26 22:29 +0100
Re: VBA Rounding "Peter T" <askformy@gmail.com> - 2015-08-27 09:50 +0100
Re: VBA Rounding Gene Haines <Gene.Haines.10256579@excelbanter.com> - 2015-08-28 01:05 +0100
Re: VBA Rounding witek <witek7205@gazeta.pl.invalid> - 2015-08-27 20:49 -0500
| From | Gene Haines <Gene.Haines.1023e9c8@excelbanter.com> |
|---|---|
| Date | 2015-08-26 22:29 +0100 |
| Subject | VBA Rounding |
| Message-ID | <Gene.Haines.1023e9c8@excelbanter.com> |
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 -- Gene Haines
[toc] | [next] | [standalone]
| From | "Peter T" <askformy@gmail.com> |
|---|---|
| Date | 2015-08-27 09:50 +0100 |
| Message-ID | <mrmisj$tnr$1@dont-email.me> |
| In reply to | #107996 |
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" <Gene.Haines.1023e9c8@excelbanter.com> wrote in message news:Gene.Haines.1023e9c8@excelbanter.com... > > 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
[toc] | [prev] | [next] | [standalone]
| From | Gene Haines <Gene.Haines.10256579@excelbanter.com> |
|---|---|
| Date | 2015-08-28 01:05 +0100 |
| Message-ID | <Gene.Haines.10256579@excelbanter.com> |
| In reply to | #107996 |
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 -- Gene Haines
[toc] | [prev] | [next] | [standalone]
| From | witek <witek7205@gazeta.pl.invalid> |
|---|---|
| Date | 2015-08-27 20:49 -0500 |
| Message-ID | <mroejo$ebn$8@dont-email.me> |
| In reply to | #107998 |
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) ?
[toc] | [prev] | [standalone]
Back to top | Article view | microsoft.public.excel.programming
csiph-web