No Round function in VBA

V

Victor Rodrigues

Hi,

I've just started using Office 2004 and one using one of my existing
worksheets discovered that Mac VBA does not have a Round function. Is there
a plugin that I am missing?

Regards,

Victor
 
J

JE McGimpsey

Victor Rodrigues said:
I've just started using Office 2004 and one using one of my existing
worksheets discovered that Mac VBA does not have a Round function. Is there
a plugin that I am missing?

No. MacXL's VBA (all versions) is stuck at version 5.00. VBA's Round()
wasn't introduced until VBA 6 (so WinXL97 doesn't have it either).

You can use the XL worksheet function, e.g.,

a = Application.Round(b)

Note that XL's ROUND() does a symmetric arithmetic rounding, in which
numbers with 5 in their least significant digit round's away from zero,
while VBA's Round() uses what MS calls "Banker's Rounding" which rounds
a 5 in the least significant digit to the nearest *even* digit:

0.014 0.015 0.016 0.025
XL: =ROUND(n, 2) 0.01 0.02 0.02 0.03
VBA6: Round(n, 2) 0.01 0.02 0.02 0.02

You can also roll your own Round() function. You can find more
information here:

http://support.microsoft.com/default.aspx?scid=kb;en-us;194983

including a link to implementing an equivalent version here:

http://support.microsoft.com/kb/196652/EN-US/

Other VBA6 functions can be implemented in VBA5 using the techniques
shown at

http://support.microsoft.com/default.aspx?scid=kb;en-us;188007
 
V

Victor Rodrigues

Thanks JE, very useful information. I suppose this information must be
buried in some compatibility document. Thanks for the help on this.

Regards,

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top