ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   File size function (https://www.excelbanter.com/excel-discussion-misc-queries/117960-file-size-function.html)

msdrolf

File size function
 
Is there a function or command which will input the size of the file I am
working on into a specified cell. I know I can look in Properties but I
need the file size to be entered into a cell which I can then link to a
summary spreadsheet which will list about 200 files and their file sizes.

Dave Peterson

File size function
 
How about a little macro:

Option Explicit
Function HowBig(Optional rng As Range) As Double

If rng Is Nothing Then
Set rng = Application.Caller
End If

HowBig = 0
If rng.Parent.Parent.Path = "" Then
'never saved
Exit Function
End If

HowBig = FileLen(rng.Parent.Parent.FullName)

End Function

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

=======

Short course:
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel to test it out.

Put
=howbig()
in an empty cell



msdrolf wrote:

Is there a function or command which will input the size of the file I am
working on into a specified cell. I know I can look in Properties but I
need the file size to be entered into a cell which I can then link to a
summary spreadsheet which will list about 200 files and their file sizes.


--

Dave Peterson


All times are GMT +1. The time now is 10:00 PM.

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