Conditional Decimal Format - excel

I want to format a number with two decimals unless it's 0. Can I do this?
123.93
23.00
144.34
0
2.38

This works great:
Go to format cells and select custom. Then paste this 0.00;[=0]0 into the Type field
from http://www.ozgrid.com/Excel/CustomFormats.htm

Try this:
=IF(A1=0,"0",TEXT(A1,"0.00"))

An alternative that includes a separator for thousands, shows negative values in red font and aligns zeros with whole numbers:
#,##0.00;[Red]-#,##0.00;0
(for the alignment, there are three blanks at the end).

From Excel Help:
A number format can have up to four sections of code, separated by
semicolons. These code sections define the format for positive
numbers, negative numbers, zero values, and text, in that order.
;;;
So All you really need to do is something like 0.00,-0.00,0

Related

Why am I obtaining this strange value multiplying 2 number having different format using Excel?

I am very new to Excel and I have a problem with a simple multiplication (I know, it is depressing but I'm stuck).
I have to multiply the numeric content of 2 cells (these value are calculated using 2 different formulas).
The problem is that it seems that these 2 cells contain numeric values having different format and I obtain a strange result.
Infact I have:
1) The K3 cell containing this value: 0,0783272400
2) The K6 cell containing this value: 728.454911165
In another cell I simply do:
=K3*K6
but now I am obtaining this nonsense value: 57.057.862.655,9996000000
I think that the problem could be related to the fact that the first one use the , do divide integer section and decimal section, and in the other one I am using . to divider the integer section and decimal section.
How can I correctly handle this situation?
Format both values as Currency in Excel and forget about the issue.
You are getting it, because the floating point values are not represented differently in many programming languages. In Excel probably the best way to make sure you do not give strange values is to format as Currency.
Or in VBA to use the CDec and to convert to decimal.
Is floating point math broken?
Excel is treating 0,0783272400 as something less than one tenth and 728.454911165 as getting on for one thousand billion. The result is formatted with . for thousands separator and , for decimal separator - and is not nonsensical (though the choice of formatting is).

Excel format cells

I have custom format cells but I don't know what does it meaning? Could you guys help me? Thank you.
0.0_);[Red](0.0)
P/s Is there any reference documents about this format ? If it exist please tell me.
A number format in excel can have up to 4 sections,
<POSITIVE>;<NEGATIVE>;<ZERO>;<TEXT>
This formatting will apply if the number in a cell is positive, negative, zero or a text respectively. In your case the format has 2 sections which is for positive and zeroes and then one for negatives.
0.0_); - for positive and zeroes
[Red](0.0) - for negatives
1) 0.0 - This is to format all the numbers to a single decimal place. For example 1234 will become 1234.0 and 1234.56 will become 1234.5
2) _) - the underscore followed by a parentheses ) is to apply spacing at the end so that it is inline with the negatives which are enclosed with parentheses.
3) [Red]() - negatives will be represented in red color font enclosed with parentheses.
A picture can speak a thousand words,
You can find more info and much more helpful formatting methods in the Microsoft Documentation and of course google

Excel remove Characters past a decimal

I have a large excel file the contains many way-points in Latitude and Longitude in the degree and minutes. My problem is that the numbers can't be rounded and must stay exactly the same, but the last 2 numbers need to be removed (in most cases)
I was wondering if there is a formula that would only allow three characters past the decimal. This is how most my numbers look.
26° 17.82964
However Sometimes they look like this
26° 9.82
I know I can format the cell as a number and set the decimal place to 3, however when I copy and paste it doesn't stay the same.
This formula will truncate (It does not Round) the numbers and give all if less:
=MID(A1,1,FIND(".",A1)+3)
This formula will round, but it will always fill out the numbers to three decimal places (I am aware the OP did not want rounding, this is for others that may want it.):
=LEFT(A1,FIND(" ",A1))&TEXT(ROUND(--MID(A1,FIND(" ",A1),LEN(A1)),3),"0.000")

Cell formatting for Millions of dollars

I'm working with large numbers here, so I want to save space in each cell by displaying
$1,782,543 as $1.78M
I'm formatting the cell using the following custom formatter:
$#.0,," M";
It seems to be working, except when the number is negative. Then it displays nothing. Any idea what could be causing this?
Perhaps there is a better way to do this.
What comes after the semi-colonis the format applied to negative values, as you have nothing after the semi-colon negative values are blank......so just leave out the semi-colon and the same format is applied to all values, positive negative or zero (but with "-" sign for negative numbers), i.e. use just
$#.0,," M"
The format for a custom number format is <positive number>;<negative number>;<zero>;<text>.
If you add some format masks for the other possible number variations you should be fine. Example:
$#.0,," M"_);[Red]($#.0,," M");[color14]_(* "-"??_);[color5]_(#_)
          
The above will supply your desired format in black digits, negative numbers in the same number format but bracketed and colored red; grey hyphen in place of zeroes and blue text.
Try this format:
$#.0,," M";-$#.0,," M";$#.0,," M";

How to format Microsoft Excel data labels without trailing decimal on round values?

(Not sure if this is the best stack for this question).
What is the format to have 14500 read as $14.5K but to have 3000 read as just $3K without the trailing decimal point?
I can't seem to comprehend the correct expression from the manual.
Excel does not appear to support this functionality using custom format codes. However, there is a way to simulate this. Create a new column that uses the function ="$"&A1/1000&"K".
Original ="$"&A1/1000&"K"
$3,500 $3.5K
$3,000 $3K
$14,500 $14.5K
$13,300 $13.3K
$25,000 $25K
$250,000 $250K
To get this to work, I formatted the cell's of the data column 4
4
4
4
3.5
13.5, by either selecting the column and then right click and format cells or by right clicking on the chart and selecting format data labels.
I formatted this with the regular expression $#K so that the data then shows as
$4K
$4K
$4K
$4K
$4K
$14K. The consequence is that the number is rounded to not include the decimal.
Now, all i needed to do was separately format the individual cell's that had decimal values by right clicking on the individual cell's and changing their format to #.0K.
Thus we now have, $4K
$4K
$4K
$4K
$3.5K
$13.5K
Also, the , can be used in the regex ($#,K for round numbers, $#.0,K for decimal) for data of thousands, like my original question.
This was an acceptable solution for me because there were only two such fractional data points.
For a larger dataset, you will need to use a conditional expression to determine all the cell's that have decimal values.
One way to do this, is like so:
If your numbers are in column B, apply this formula for column C
=B1=INT(B1)
This will show TRUE if the data is of INT data type (no decimal precision) and FALSE if not.
Now, select column C and select Data\Filter\Autofilter
From the drop-down list in C1, select FALSE
This will show only the decimal numbers and hide the whole numbers.
And now you can apply the relevent formatting as described above.

Resources