Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cutting off numbers to two decimal places using a SCRIPT
Hi, I would like to know if any of you would know how to change the cel
contents in the following situation: I enter 2.1342 I want excel to change it to 2.13 not just changing the formatting, but actually changing the number t round to the hundreths place. When I go back to that cell, I don' want to know that there was ever a number there besides 2.13, does tha make sense? I want it to edit my number for me. Thanks ahead of time, We -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cutting off numbers to two decimal places using a SCRIPT
Two choices
1. Either put a formula into a target cell on the worksheet referencing the cell with the source Range("D2").Formula = "=ROUND(B2,2)" 2. Or in program use YourNumber = Round(YourNumber, 2) Cheers Nigel "tilt64 " wrote in message ... Hi, I would like to know if any of you would know how to change the cell contents in the following situation: I enter 2.1342 I want excel to change it to 2.13 not just changing the formatting, but actually changing the number to round to the hundreths place. When I go back to that cell, I don't want to know that there was ever a number there besides 2.13, does that make sense? I want it to edit my number for me. Thanks ahead of time, Wes --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cutting off numbers to two decimal places using a SCRIPT
You can do it without VBA if you choose Tools/Options/Calculation and
check the Precision as displayed checkbox. However that's a global setting for the workbook, so you may not want to use that. If the value is a result of a calculation, wrap the calc with ROUND: =ROUND(<your calc here,2) Using VBA, if the entry is made manually or remotely, put this in the worksheet code module: Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("A1")) Is Nothing Then Application.EnableEvents = False With Range("A1") .Value = Application.Round(.Value, 2) End With Application.EnableEvents = True End If End Sub In article , tilt64 wrote: Hi, I would like to know if any of you would know how to change the cell contents in the following situation: I enter 2.1342 I want excel to change it to 2.13 not just changing the formatting, but actually changing the number to round to the hundreths place. When I go back to that cell, I don't want to know that there was ever a number there besides 2.13, does that make sense? I want it to edit my number for me. Thanks ahead of time, Wes |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Why do my numbers keep going down decimal places? | Setting up and Configuration of Excel | |||
Why do my numbers keep going down decimal places? | Setting up and Configuration of Excel | |||
Sum of numbers with only two decimal places wrong | Excel Discussion (Misc queries) | |||
Subtracting two 2-decimal place numbers gives result 13-decimal places? | Excel Worksheet Functions | |||
Trim numbers to x decimal places | Excel Programming |