Shippwreck
Programmer
Hi,
I thought this would be simple, but i'm having issues getting it to work!
Basically i'm trying to create a macro in Excel where i give it a folder and a minimum file size (Mb, Kb, b, it doesn't matter) and it looks through the drive and lists in columns a and b all the file names and the file size of files greater than the specified size.
I have code (taken from the excel help files) that lists out all the files in a single folder and there size using the following:
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
If f1.size / 1024 / 1024 > size Then
s = s & f1.Name & FormatNumber(f1.size / 1024 / 1024, 0)
s = s & vbCrLf
End If
Next
MsgBox s
yes i know its a message box, just trying to get it to work! but i can;t work out how to get it to look through subfolders of that folder, any ideas???
Any help is greatly appreciated, thanks!
"Google is god...of the internet" - Me
I thought this would be simple, but i'm having issues getting it to work!
Basically i'm trying to create a macro in Excel where i give it a folder and a minimum file size (Mb, Kb, b, it doesn't matter) and it looks through the drive and lists in columns a and b all the file names and the file size of files greater than the specified size.
I have code (taken from the excel help files) that lists out all the files in a single folder and there size using the following:
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 In fc
If f1.size / 1024 / 1024 > size Then
s = s & f1.Name & FormatNumber(f1.size / 1024 / 1024, 0)
s = s & vbCrLf
End If
Next
MsgBox s
yes i know its a message box, just trying to get it to work! but i can;t work out how to get it to look through subfolders of that folder, any ideas???
Any help is greatly appreciated, thanks!
"Google is god...of the internet" - Me