Re: VBA round

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



The Round method was introduced into VBA in VBA6 (XL2000 and later). If
you're using XL97 or MacXL, use

Range("A1").Value = Application.Round(X)

Note that VBA's Round and XL's ROUND treat a 5 in the last significant
digit differently - XL always rounds away from zero, VBA always rounds
to the nearest even digit:

VBA: Round(2.5, 0) ===> 2
Round(3.5, 0) ===> 4

XL: Round(2.5,0) ===> 3
Round(3.5,0) ===> 4


In article <67048C96-E40C-41A2-BB42-A276965DF99E@xxxxxxxxxxxxx>,
"Jeff" <Jeff@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> I am writing VBA.
>
> How do I round.
>
> I tried "Range("A1").value = Round(X)"
> where I set X = 6.7
>
> But it gave an error on the "Round()" - it said it was not defined function.
> Is there a function that can round in VBA?
.


Quantcast