Display File Size in Cell

sachavez

Active Member
Joined
May 22, 2009
Messages
469
Excel 2007

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

Thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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()
 
Upvote 0
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?
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,214,572
Messages
6,120,306
Members
448,955
Latest member
Dreamz high

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top