简体   繁体   English

另一个Excel公式情况

[英]Another excel formula situation

I want to be able to display a difference in seconds as (+4.15) or sometimes negatively as (-4.15) and include the parentheses and plus/minus sign. 我希望能够将以秒为单位的差异显示为(+4.15)或有时显示为负数(-4.15),并包括括号和加/减号。

How can I use a formula to display 34.47-30.32 so it comes out knowing whether or not the difference is positive or negative 4.15? 我如何使用公式显示34.47-30.32,这样才能知道差异是正数还是负数4.15?

This is solved now except my next issue is small, but any number ending in 0, such as 4.10, will display as 4.1, without the extra 0. Using the formula given in the first comment, I can't format this to show exactly 4.10. 现在已经解决了,除了我的下一个问题很小,但是任何以0结尾的数字(例如4.10)将显示为4.1,而没有多余的0。使用第一个注释中给出的公式,我无法格式化此格式以准确显示4.10。 Is it possible? 可能吗? not even cell formatting to show two decimal places works 甚至没有单元格格式显示两位小数

You can achieve this with the regular cell formats option in excel. 您可以使用excel中的常规单元格格式选项来实现此目的。

Format your cells to show the number in this way. 格式化单元格以这种方式显示数字。 Or if you need something other than the already available options, then use custom formats. 或者,如果您需要除现有选项之外的其他选项,请使用自定义格式。

在此处输入图片说明

Something like this should work: 这样的事情应该起作用:

=TEXT(B1-A1,"+##.##;-##.##")

Though as Jon says - editing the cell format is far more appropriate generally to avoid an issue, select custom and use this: 尽管正如Jon所说的那样,编辑单元格格式通常更合适以避免问题,但请选择custom并使用:

+##.##;-##.##

Your desired results (eg +4.15 and -4.15 ) are not covered by the various available standard number formats but you can easily apply a custom number format aka CNF. 各种可用的标准数字格式未涵盖您想要的结果(例如+4.15和-4.15),但是您可以轻松地应用自定义数字格式(也称为CNF)。

A CNF can have up to four parts; CNF最多可以包含四个部分; positive numbers, negative numbers, zero and text. 正数,负数,零和文本。 The following will display positive numbers as black and a plus sign, negative numbers as red with a minus sign, a single grey dash instead of zero and blue text. 下面将显示正数为黑色和加号,负数为红色加减号,用一个灰色破折号代替零和蓝色文本。 The latter should never be actually used but the blue text will quickly show text that should have been interpreted as a number. 绝对不要使用后者,但是蓝色文本会很快显示应该解释为数字的文本。 The true numbers will be 'padded' off the right edge by a single space. 真实数字将在右侧边缘“填充”一个空格。

[Black]_(+#,##0.00_);[Red]_(-#,##0.00_);[Color10]_(* "-"_);[Blue]_(@_)

Example: 例:

在此处输入图片说明

More on custom number formats at Create or delete a custom number format 有关创建或删除自定义数字格式的更多有关自定义数字格式的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM