Re: Truncating a cell value AFTER the decimal place

From: Medemper (notmyaddress_at_here.now)
Date: 02/20/04


Date: Fri, 20 Feb 2004 12:30:32 -0600

If you are always removing the last digit of the value:

Sub truncateLastDigit()
temp = ActiveCell.Value
ActiveCell.Value = Left(temp, Len(temp) - 1)
End Sub

  "nano >" <<nano.11xstf@excelforum-nospam.com> wrote in message news:nano.11xstf@excelforum-nospam.com...
  I am assuming that the following question has a simple solution, however
  I haven't found the answer after quickly searching the forum and a VBA
  book.

  I would like to truncate the cell value in the following manner:

  25.7873 to 25.787

  My understanding of the truncate function is that it will truncate the
  value to 25 and I have tried formatting the number with the following:

  Selection.NumberFormat = "#.##0"

  The NumberFormat only altered the displayed number, not the value of
  the number. How can I easily accomplish this.

  Thanks in advance,
  Bruce

  ---
  Message posted from http://www.ExcelForum.com/



Relevant Pages

  • Re: Rounding errors
    ... >> Intuition tells us half the numbers will round up and half will ... >> Let's round each group the Cobol way and sum the rounded numbers. ... >contrived to truncate after the third digit. ...
    (comp.lang.cobol)
  • Re: Rounding errors
    ... contrived to truncate after the third digit. ... "We" don't criticise floating-point for 'rounding errors' ... We criticise floating-point for not being able to represent ...
    (comp.lang.cobol)
  • Re: Instead of DBO
    ... Anyone can create temp table. ... When you say TRUNCATE TABLE, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: Trucate Command
    ... Insert into temp select * from real_table where date_col between ... Truncate the original table -- This step will ... you can not do any kind of recovery using truncate table command. ... into syntax will look as follows. ...
    (microsoft.public.sqlserver.mseq)
  • Re: Update Query w/user input, Need to add a formula.
    ... They will be entering in a 5 digit PO ... here is the formula to truncate it. ... How do i enter this into the query, so after it is prompted this formula ...
    (microsoft.public.access.queries)