Round function in Excel, worksheet function vs VBA

10,132

It's a known issue. The VBA Round() function uses Banker's rounding while the spreadsheet cell function uses arithmetic rounding. Check the details here:

PRB: Round Function different in VBA 6 and Excel Spreadsheet

The workaround proposed by Microsoft is to write a custom function to get the desired results.

Banker's rounding always rounds 0.5 to the nearest even number and is standard in accounting, which is why Excel works that way. Arithmetic rounding rounds 0.5 up to the next number.

Share:
10,132
Vaibhav Garg
Author by

Vaibhav Garg

I am an embedded firmware engineer in Power Industry. I am also well versed in embedded design and C. I have a fair amount of interest in data analysis tools and am an intermediate to advanced user of MS excel. Of late, I have also dabbled in systems engineering.

Updated on June 05, 2022

Comments

  • Vaibhav Garg
    Vaibhav Garg almost 2 years

    I had an application for returning closest matches to certain values in a large cluster of values( as in my earlier question) and I chose a VBA solution. While in the course of using the said application, I observed that the results for the value of 0.5 were not correct. I had been using the VBA Round function which I found to be returning 0 for 0.5 rounded to integer whereas the worksheet round function returns 1. Strangely, the VBA round function returns 2 for 1.5. I had to substitute the worksheet function in place of the VBA one.

    Am I missing something?