Excel number format to only show decimals when necessary

后端 未结 6 1216
旧巷少年郎
旧巷少年郎 2021-01-12 00:32

How can I, without using formulas, show integers as integers, but decimals limited to a specific number of decimal places.

e.g. show: 1 as 1

6条回答
  •  旧巷少年郎
    2021-01-12 00:44

    If acceptable, you may use the formula not in the sheet but as a condition for Conditional Formatting.

    When your data is at A1:A4 as the sample on screenshot, we should create 2 Formatting Rules:

    1. Formula is: =MOD($A1,1) = 0 Applies to: =$A$1:$A$4 Format the number as no decimals from the format of this rule.
    2. Formula is: =MOD($A1,1) <> 0 Applies to =$A$1:$A$4 & Format the number to show 2 decimals.

    Actually the 2nd condition is optional. You may format the whole column with 2 decimals and conditional format with the first rule so only the integers will have no decimals.

    Please see my sample screenshot:

提交回复
热议问题