+ Reply to Thread
Results 1 to 8 of 8

How do I prevent the decimal value being used?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-22-2010
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    4

    How do I prevent the decimal value being used?

    How do I format a cell to prevent the decimal value from being used in calculations?

    If I format the cell to "0" decimal places it still calculates with the decimal value and I only want to use the whole number in calculations, is there a way to do this?

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: How do I prevent the decimal value being used?

    Hi Tusk, welcome to the forum.

    Two ways may work:

    1. In your formula, don't just reference the cell, e.g. "=A1*5". Instead, use the INT() function when referencing the cell. "=INT(A1)*5"

    2. Don't allow users to enter decimal values in the cell to begin with, only whole numbers. You can do this by adding Data Validation to the cell. You can set it to Whole Number and choose additional criteria if necessary (e.g. Greater Than x, or Between x and y, etc.)

  3. #3
    Registered User
    Join Date
    10-22-2010
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: How do I prevent the decimal value being used?

    Thanks Paul!

    The "=INT(A1)*5" is what I,m looking for

    Much apreciated

  4. #4
    Registered User
    Join Date
    10-22-2010
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: How do I prevent the decimal value being used?

    Paul do you know what the equivalent in Java script of "=INT(A1)" would be?

    Thanks

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,945

    Re: How do I prevent the decimal value being used?

    The JavaScript floor() method rounds a number DOWNWARDS to the nearest integer, and returns the result
    var MyInt = Math.floor(x)
    Ben Van Johnson

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,852

    Re: How do I prevent the decimal value being used?

    Quote Originally Posted by Tusk View Post
    Thanks Paul!

    The "=INT(A1)*5" is what I,m looking for

    Much apreciated
    Do be aware that if you have a cell in Excel formatted for 0 decimal places, the number you see is rounded to the nearest integer, whereas in the INT function the decimal part is truncated. So if you want to do arithmetic on the number you see, you should use

    =ROUND(A1,0)*5
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How do I prevent the decimal value being used?

    Alternately, you could set the workbook to "Precision as displayed". Then what you see is what you get. This feature (in Excel Options) is not protected though so an individual could turn it on or off.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  8. #8
    Registered User
    Join Date
    10-22-2010
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: How do I prevent the decimal value being used?

    Thanks Proton!

    The JavaScript floor() method is what I am looking for much apreciated


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1