Rounding a number that is entered into a cell to the nearest thousand.

SanFelippo

Board Regular
Joined
Apr 4, 2017
Messages
124
Hi,

I have a cell that someone will be manually typing a number into. After they enter the number, I need that number to be rounded to the nearest thousand. Since this cell is one that will be manually typed into, this automatic rounding of whatever number they put into the cell has to be done with VBA.

My issue is the round function in VBA uses Bankers rounding, which basically means it will round up or down in order to always land on an even number.

Can anyone throw together a quick one or two lines of code that will take the number that is entered into the cell and then round it to the nearest thousand (for example if $1500 was entered for example, it would automatically round it to $2000)?

Should be simple. If you want more specifics, the cell I am trying to do this to is B29.

Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
My issue is the round function in VBA uses Bankers rounding, which basically means it will round up or down in order to always land on an even number.

If that is your only issue, use WorksheetFunction.Round(...,-3). The latter implements Excel ROUND.

More specifically:

Range("B29").Value2 = WorksheetFunction.Round(Range("B29").Value2,-3)

I use .Value2 instead of .Value because it is unclear how you have B29 formatted, and .Value has undesirable side-effects sometimes.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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