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

夙愿已清 提交于 2019-12-07 17:00:52

问题


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'.

  • € 1.000 -> € 1,0 K
  • € 1.000.000 -> € 1,0 M
  • € 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.

The question is, whether there is a way to add more than two conditions.


回答1:


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.

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.

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.



来源:https://stackoverflow.com/questions/32614844/how-to-use-multiple-conditional-operators-in-a-custom-number-format-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!