Display File Size in Cell

sachavez

Active Member
Joined
May 22, 2009
Messages
446
Excel 2007

Is there a formula or function that will display the file size in a selected cell?

Thanks
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Simon Lloyd

Well-known Member
Joined
Sep 10, 2006
Messages
756
You can create a UDF like this:
Code:
Function FileSize() As Variant
FileSize = FileLen(ActiveWorkbook.Name) / 1000000 & " Mb"
End Function
Then in your cell use: =FileSize()
 

sachavez

Active Member
Joined
May 22, 2009
Messages
446
Thanks for the reply, Simon.

I am familiar with UDFs and installed the code and UDF as described. However, my result is #Value!.

Do you have any suggestions as to why I'm getting this result?
 

yytsunamiyy

Well-known Member
Joined
Mar 17, 2008
Messages
963
FileLen() requires the full path - so you'll need

Code:
Function FileSize() As Variant
      FileSize = FileLen(ActiveWorkbook.[COLOR=red][B]FullName[/B][/COLOR]) / 1000000 & " Mb"
End Function

edit: mind you, FileLen will only return the file size before opening.
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,108,918
Messages
5,525,623
Members
409,657
Latest member
19JimRon72

This Week's Hot Topics

Top