rounding to nearest 50

foxhound

Board Regular
Joined
Mar 21, 2003
Messages
182
Does anyone know the code that would round the value of a field to the nearest 50?

Foxhound
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
In a query use something like
MyNewNumber: Int(([MyOldNumber]+25)/50)*50

Peter
 
Upvote 0
cint() and clng() round off (though it seems anomalous; it seems that the general behavior of integer operations is to round down). Thus MyNewNumber: CInt([MyOldNumber]/50) works too.
 
Upvote 0
I am trying to round up to the nearest 1000. If I use:

1000*CInt([MyOldNumber]/1000

it rounds up/down. Any suggestions?

Thank you.
 
Upvote 0
Thanks for your reply. It still rounds up/down. For example, 12400 rounds down to 12000. I want it to round up to 13000.

Thanks.
 
Upvote 0
It doesn't for me. I did have a paren missing though:

1000 * (CInt((1000 + MyOldNumber) / 1000))

If you placed it in the wrong place, it may have rounded incorrectly. When I used 12300 for MyOldNumber, I got 13000.

-Russell
 
Upvote 0
Russell that has an error. I believe you meant to use a 500 instead of 1000, as in 1000 * (CInt((500 + MyOldNumber) / 1000)).

Another way to go could be 1000 * (Int((999.999 + MyOldNumber) / 1000))

These all regard rounding UP, not NEAREST, as the thread was varied.
 
Upvote 0

Forum statistics

Threads
1,221,579
Messages
6,160,616
Members
451,658
Latest member
NghiVmexgdhh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top