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

前端 未结 16 1520
忘了有多久
忘了有多久 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条回答
  •  时光说笑
    2020-12-22 19:03

    After seeing the answers here just improved on this formula to have decimal places on bigger values and cater for negative values.

    =IF(A1<999500000000,TEXT(A1,"#,##.#0,,,"" TB"""),
    IF(A1<-9995000000,TEXT(A1,"#,##.#0,,,"" GB"""),
    IF(A1<-9995000,TEXT(A1,"#,##0,,"" MB"""),
    IF(A1<-9995,TEXT(A1,"#,##0,"" KB"""),
    IF(A1<-1000,TEXT(A1,"#,##0"" B """),
    IF(A1<0,TEXT(A1,"#,##0"" B """),
    IF(A1<1000,TEXT(A1,"#,##0"" B """),
    IF(A1<999500,TEXT(A1,"#,##0,"" KB"""),
    IF(A1<999500000,TEXT(A1,"#,##0,,"" MB"""),
    IF(A1<999500000000,TEXT(A1,"#,##.#0,,,"" GB"""),
    TEXT(A1,"#,##.#0,,,,"" TB""")))))))))))
    

提交回复
热议问题