简体   繁体   English

如何在自定义数字格式 Excel 中使用多个条件运算符?

[英]How to use multiple conditional operators in a custom number format Excel?

My brother asked my help formatting a Worksheet.我哥哥请我帮忙格式化工作表。 He wants thousands to be formatted with 'K', millions with 'M' and trillions billions with 'T' 'B'.他希望用“K”格式化数千,用“M”格式化数百万,用 “T” “B”格式化数 万亿

  • € 1.000 -> € 1,0 K € 1.000 -> € 1,0 K
  • € 1.000.000 -> € 1,0 M 1.000.000 欧元 -> 100 万欧元
  • € 1.000.000.000 -> € 1,0 B € 1.000.000.000 -> € 1,0 B

I found the following custom format on the Internet ( here )我在网上找到了以下自定义格式( 这里

[>=1000000] $#,##0.0,,"M";[<1000000] $#,##0.0,"K";General

I adapted this to我适应了这个

[>999999] $#,##0.0,,"M";[>999] $#,##0.0,"K";General

Adding more conditions will result in an error.添加更多条件会导致错误。

[>999999999] $#,##0.0,,,"B";[>999999] $#,##0.0,,"M";[>999] $#,##0.0,"K";General

Finally, this seems to work when I ignore the numbers under one thousand.最后,当我忽略一千以下的数字时,这似乎有效。

[>999999999] $#,##0.0,,,"B";[>999999] $#,##0.0,,"M";$#,##0.0,"K"

In the end, I just made a formula that does the formatting, dividing the number and concatenating the €uro sign and the K, M or B.最后,我只是做了一个公式来进行格式化,将数字除以并将 €uro 符号和 K、M 或 B 连接起来。

The question is, whether there is a way to add more than two conditions.问题是,是否有办法添加两个以上的条件。

I think the solution, such as it is, lies in your choice of tag: Conditional Formatting.我认为解决方案,例如它,在于您选择的标签:条件格式。 The custom formatting rules you refer to show research but seem not to meet your brother's requirement (eg $ cf ) so I am uncertain what exactly the content to be formatted is and am assuming these are number values.您引用的自定义格式规则显示了研究,但似乎不符合您兄弟的要求(例如$ cf ),因此我不确定要格式化的内容究竟是什么,并假设这些是数字值。

Also that you will be able to convert for a locale that suits you, the requirement is for Windows, not OSX, negative numbers need not be considered and Euro cents are irrelevant.此外,您将能够转换为适合您的语言环境,要求是针对 Windows,而不是 OSX,不需要考虑负数,并且欧分无关紧要。

HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true: :主页 > 样式 - 条件格式,新规则...,使用公式来确定要格式化哪些单元格以及在此公式为真的情况下格式化值::

=AND(A1>0,A1<1000000)

Format... , select Number tab, Category: Custom and:格式... ,选择数字选项卡,类别:自定义和:

"€ "#.0, " K"  

OK, OK.好的好的。 Then another formula rule:然后是另一个公式规则:

=AND(A1>999999,A1<1000000000)  

with format:格式:

"€ "#.0,, " M"  

and a third formula rule of:和第三个公式规则:

=A1>999999999  

with format:格式:

 "€ "#.0,,, " T"  

The order in which the rules are applied may be significant.应用规则的顺序可能很重要。

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

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