Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do my numbers keep going down decimal places? Excell2002ishard Setting up and Configuration of Excel 2 March 27th 08 09:36 PM
Why do my numbers keep going down decimal places? Excell2002ishard Setting up and Configuration of Excel 2 March 27th 08 08:09 PM
Sum of numbers with only two decimal places wrong Excelgonecrazy Excel Discussion (Misc queries) 2 November 13th 07 07:21 PM
Subtracting two 2-decimal place numbers gives result 13-decimal places? [email protected] Excel Worksheet Functions 5 March 12th 07 10:38 PM
Trim numbers to x decimal places Andrea[_8_] Excel Programming 7 February 26th 04 03:04 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"