ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Rounding down numbers in cell (https://www.excelbanter.com/excel-discussion-misc-queries/140787-rounding-down-numbers-cell.html)

[email protected]

Rounding down numbers in cell
 
I'm trying to format a cell to round numbers DOWN as I type them.
Right now, Excel seems to only round numbers UP. Is there any way to
do this without using the ROUNDDOWN formula? I know I can use the
ROUNDDOWN formula, but that only works if he formula is in a different
cell from the data. Thanks.


Peo Sjoblom

Rounding down numbers in cell
 
You can never get Excel to round numbers by using formatting, the display
rounds up or down depending on the number, however the underlying value is
still the same. You can only get this upon entry by using an event macro


--
Regards,

Peo Sjoblom



wrote in message
ups.com...
I'm trying to format a cell to round numbers DOWN as I type them.
Right now, Excel seems to only round numbers UP. Is there any way to
do this without using the ROUNDDOWN formula? I know I can use the
ROUNDDOWN formula, but that only works if he formula is in a different
cell from the data. Thanks.




JE McGimpsey

Rounding down numbers in cell
 
Formatting won't actually round values up or down, unless you have the
Tools/Options/Calculation/Precision as displayed checkbox checked.

To actually round values down as you type, you'd need an event macro.
You could put something like this in your worksheet code module
(right-click the worksheet tab and choose View Code):

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const csINPUTRNG As String = "A1:A100, C1:C100"
Const cnDECPLACES = 2
Dim dScale As Double

With Target
If Not Intersect(Range(csINPUTRNG), Target) Is Nothing Then
dScale = 10 ^ -cnDECPLACES
On Error Resume Next
Application.EnableEvents = False
.Value = Int(.Value / dScale) * dScale
Application.EnableEvents = True
End If
End With
End Sub


In article . com,
wrote:

I'm trying to format a cell to round numbers DOWN as I type them.
Right now, Excel seems to only round numbers UP. Is there any way to
do this without using the ROUNDDOWN formula? I know I can use the
ROUNDDOWN formula, but that only works if he formula is in a different
cell from the data. Thanks.



All times are GMT +1. The time now is 10:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com