• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to avoid decimal places

Aqib Islam

New Member
Hi,

I am creating an excel workbook in which I dont want to have any values with decimal places. For example if any one enters a number that contains decimal places, excel ignores decimal places. Please advise if there are any settings for this purpose.

Thanks in advance
 
Select the column(s) in question and set their format type from general to number (drop-down on the Home ribbon). Use the button on the ribbon to decrease the number of decimal places to zero.
 
Select the column(s) in question and set their format type from general to number (drop-down on the Home ribbon). Use the button on the ribbon to decrease the number of decimal places to zero.
Thanks but the cell still has decimal digits in it although not displayed I want to excel to automatically remove decimals
 
Aqib Islam
As You wrote:
(#1) If any one enters a number that contains decimal places, excel ignores decimal places.
As well as:
(#3) I want to excel to automatically remove decimals
 
Hi,

Other than above, you can use Data Validation to restrict decimals with following:

Select your cell(s)
Go to Data > Data Validation > Custom:

=INT(A1)=A1

Regards,
 
Follow AliGW's advice and then, if you are really determined to do what you say, go into 'Options' and under Calculation select 'Set Precision as Displayed".

Bear in mind that it is a risky setting that will eventually tend to accumulate errors in the tens or hundreds rather than keeping errors bounded at the level of billionths.

vletm The macro was brutal. The sheet wouldn't even accept a formula!
 
Peter Bartholomew
Ouch!
If someone would 'avoid decimal places', that will do it!
You comment that The sheet wouldn't even accept a formula!
Did You test eg to write =1+2? I did.
Everywhere would be side effects, even water!
 
vletm
If I remember correctly what I did was enter a few numbers like 3.65 in B7:B10 and then, to see what was stored, I typed a formula
= B7 * 1000
and filled down.

The first calculation
1000 x 3.65 = 4000
did not come as too much of a surprise but the fact that every other result in the column was also 4000 did cause me to go looking for the macro.
 
Peter Bartholomew - As needed:
If any one enters a number that contains decimal places, excel ignores decimal places. I want to excel to automatically remove decimals.
And Your test ... didn't it work then?
If You wrote to B7 3,65 to cell and pressed <ENT>
... it removed decimals and gives 3.
If You wrote to C7 =B7*1000 and pressed <ENT>
... it gives 3000.
If You then filled down, then ... it works too.
Your the first calculation was 3*1000, which is 3000.
The first sentence was ...
enters a number... .
I've many Excel-files, which do not have so many formulas or even none.
If someone would like to use formulas with this, it is possible to do too!

Same file, with some formulas in range E4:E9.
 

Attachments

  • aqibislam.xlsb
    35.2 KB · Views: 3
Back
Top