Report File Size in Excel

Shinho62

New Member
Joined
Mar 16, 2011
Messages
26
Excel Query

Morning everyone, wondered if someone could point me in the right direction, i need excel to be able to report on the size of a file in a specific folder on a remote computer and list that size in excel

For Example

an access file at location

\\ComputerName\Storage\DB1.mdb

All the folders are shared so access to them is ok, but i have many locations on one machine and lots of machines

would appreciate it if someone could advsie of the correct formula to use

thanks in advance;)
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hello there

For the size in bytes in cell A1:

Code:
Range("A1").Value = CreateObject("Scripting.FileSystemObject").GetFile("YOUR FILE").Size

Change YOUR FILE with the correct file location.
 
Upvote 0
Hello

This is a macro for VBA. Go to VBA, for instance using Alt-F11. Insert a module in your workbook (or use an existing module if you already have one). Then paste this code:

Code:
Sub PutFileSize()
   Range("A1").Value = CreateObject("Scripting.FileSystemObject").GetFile("YOUR FILE").Size
End Sub

Then, close VBA. In Excel, call the macros window, for instance using Alt-F8. Run the macro and look at cell A1 for the result. Do not forget to insert your path and filename in the code.

Alternatively, the macro could also be a function that you can use in a worksheet. If you want that, please indicate so.
 
Upvote 0
Wigi,

thats great works well on just the one file, but i have multiple
is there a way to have it read a column in excel and report those file sizes ?:)
 
Upvote 0
In many many other topics, you will find examples of For ... Next loops. Please browse the other topics to see other code examples.

For instance:

Code:
Sub PutFileSize()
   Dim l As Long
   With CreateObject("Scripting.FileSystemObject")
     For l = 2 To Range("A" & Rows.Count).End(xlUp).Row
       Range("B" & l).Value = .GetFile(Range("A" & l).Text).Size
     Next
   End With
End Sub

Column A has files and paths, column B will contain the file size.
 
Upvote 0
Hi Wigi,

hope this post finds you well

from the code you provided previously, of which is still working fab thanks, is there a way to get it to list all the documents properties as well as its filename

thanks in advance

Darren;)
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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