Convert bytes to kilobytes or megabytes?

T

Toney

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
 
B

Bob Phillips

=IF(A5<10^3,A5&"
bytes",IF(A5<10^6,ROUND(INT(A5/10^3),-1)&"k",ROUND(INT(A5/10^6),1)&" megs"))
 
L

Luke M

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

Toney

Thanks for your help. Between the two answers i figured out how to do this.

Thanks again

Toney
 
T

Toney

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top