ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Convert bytes to kilobytes or megabytes? (https://www.excelbanter.com/excel-worksheet-functions/242314-convert-bytes-kilobytes-megabytes.html)

Toney

Convert bytes to kilobytes or megabytes?
 
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[_3_]

Convert bytes to kilobytes or megabytes?
 
=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" wrote in message
...
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




Luke M

Convert bytes to kilobytes or megabytes?
 
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!*


"Bob Phillips" wrote:

=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" wrote in message
...
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





Toney

Convert bytes to kilobytes or megabytes?
 
Thanks for your help. Between the two answers i figured out how to do this.

Thanks again

Toney

Toney

Convert bytes to kilobytes or megabytes?
 
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

[email protected]

Convert bytes to kilobytes or megabytes?
 
On Friday, September 11, 2009 at 1:16:02 PM UTC-7, Toney wrote:
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


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"))))


All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com