Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert bytes to kilobytes or megabytes?

2,963 views
Skip to first unread message

Toney

unread,
Sep 10, 2009, 2:25:58 PM9/10/09
to
I have a list of files that include the file size listed in bytes. I need to
convert these files sizes into Megs or K's or leave them as bytes. For
example what I have is...

File name Size in bytes
Tiny file 3
Medium file 153,600
Large file 5,242,880

What I need is...
File name Size
Tiny file 3 bytes
Medium file 150k
Large file 5 megs

Any ideas?

Thanks in advance
Toney

Bob Phillips

unread,
Sep 10, 2009, 2:35:18 PM9/10/09
to
=IF(A5<10^3,A5&"
bytes",IF(A5<10^6,ROUND(INT(A5/10^3),-1)&"k",ROUND(INT(A5/10^6),1)&" megs"))

--
__________________________________
HTH

Bob

"Toney" <To...@discussions.microsoft.com> wrote in message
news:F6331228-7918-4CBB...@microsoft.com...

Luke M

unread,
Sep 10, 2009, 3:26:45 PM9/10/09
to
One kilobyte <> 1000 bytes. (based on OP's example and result, he is using
the correct calculation of 1 kb = 2^10 bytes.

=IF(A5<2^10,A5&" bytes",IF(A5<2^20,ROUND
(INT(A5/2^10),-1)&"k",ROUND(INT(A5/2^20),1)&" megs"))


--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*

Toney

unread,
Sep 11, 2009, 4:15:02 PM9/11/09
to
Thanks for your help. Between the two answers i figured out how to do this.

Thanks again

Toney

Toney

unread,
Sep 11, 2009, 4:16:02 PM9/11/09
to
Thanks for your help. Your reply was just a bit more spot on with the using
the 1024 byte/k. Between the two answers I figured out how to do this.

Thanks again

Toney

danie...@gmail.com

unread,
Oct 23, 2018, 9:02:43 PM10/23/18
to
Sorry for the 9 year old thread resurrection, but here is an expansion that covers through petabytes in case anyone finds it useful :)


=IF(A5<2^10,A5&" bytes",IF(A5<2^20,ROUND (INT(A5/2^10),-1)&"kb",IF(A5<2^30,ROUND (INT(A5/2^30),-1)&"mb",IF(A5<2^40,ROUND (INT(A5/2^30),-1)&"gb",ROUND(INT(A5/2^40),1)&" tb"))))
0 new messages