Please accept my sincerest apologies if the title or question is confusing.
I am using VBA in Excel 2007. I need to round a number to the nearest 500.
I am using the code:
Rvariable = Round(variable / 500, 0) * 500
My available numbers that I am trying to round go from -500
to 10000
.
If the value to be rounded is from 501
to 749
, it will round down appropriately (i.e. 2501
to 2749
rounds to 500
). 750's
appropriately round up (2750
rounds to 3000
). Values from 001
to 249
also round down correctly, and 251
to 499
round up correctly.
For some reason, a 250
value still rounds down (2250
rounds to 2000
not 2500
). It will not round up until 251
. When I use this function in the actual excel worksheet, the Round
function works properly and will round up at 250
.