How can I format bytes a cell in Excel as KB, MB, GB etc?

前端 未结 16 1653
忘了有多久
忘了有多久 2020-12-22 18:46

I have a value in a cell that\'s in bytes. But nobody can read 728398112238. I\'d rather it say 678.37GB

To write a formula to format it relatively easy (here\'s one

16条回答
  •  萌比男神i
    2020-12-22 18:55

    The above formatting approach works but only for three levels. The above used KB, MB, and GB. Here I've expanded it to six. Right-click on the cell(s) and select Format Cells. Under the Number tab, select Custom. Then in the Type: box, put the following:

    [<1000]##0.00"  B";[<1000000]##0.00," KB";##0.00,," MB"
    

    Then select OK. This covers B, KB, and MB. Then, with the same cells selected, click Home ribbon, Conditional Formatting, New Rule. Select Format only cells that contain. Then below in the rule description, Format only cells with, Cell Value, greater than or equal to, 1000000000 (that's 9 zeros.) Then click on Format, Number tab, Custom, and in the Type: box, put the following:

    [<1000000000000]##0.00,,," GB";[<1000000000000000]##0.00,,,," TB";#,##0.00,,,,," PB"
    

    Select OK, and OK. This conditional formatting will take over only if the value is bigger than 1,000,000,000. And it will take care of the GB, TB, and PB ranges.

    567.00  B
      5.67 KB
     56.70 KB
    567.00 KB
      5.67 MB
     56.70 MB
    567.00 MB
      5.67 GB
     56.70 GB
    567.00 GB
      5.67 TB
     56.70 TB
    567.00 TB
      5.67 PB
     56.70 PB
    

    Anything bigger than PB will just show up as a bigger PB, e.g. 56,700 PB. You could add another conditional formatting to handle even bigger values, EB, and so on.

提交回复
热议问题