Finding Date of Folders

drsparks

New Member
Joined
Jul 20, 2010
Messages
3
I currently have a code that pulls the name, path, and size of a file from the directory. I need this code to also like the date range for the folder. (could be created to last modified). Below is the current code. any help would be appreciated.

Sub ListFoldersAndInfoSystemsFolder()
Dim FSO As Object
Dim Folder As Object
Dim FolderName As String
Dim R As Long
Dim Rng As Range
Dim SubFolder As Object
Dim Wks As Worksheet

FolderName = "I:\Systems\"

Set Wks = Worksheets("Sheet2")
Set Rng = Wks.Range("A2")
Wks.UsedRange.Offset(1, 0).ClearContents

Set FSO = CreateObject("Scripting.FileSystemObject")

Set Folder = FSO.GetFolder(FolderName)
R = Rng.Row
Rng.Cells(1, 1) = Folder.Name
Rng.Cells(1, 2) = Folder.Path
Rng.Cells(1, 3) = Folder.Size

For Each Folder In Folder.SubFolders
Rng.Cells(R, 1) = Folder.Name
Rng.Cells(R, 2) = Folder.Path
Rng.Cells(R, 3) = Folder.Size
R = R + 1
Next Folder

Set FSO = Nothing

Sheets("Sheet2").Select
Cells.Find(What:="Projects", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Selection.EntireRow.Delete


End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

drsparks

New Member
Joined
Jul 20, 2010
Messages
3
I tried it did not work. the output it produced was ....

40255.4381018519

and

40375.404849537
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try e.g.

Code:
Format(Folder.DateCreated, "dd/mm/yyyy hh:mm")
 

drsparks

New Member
Joined
Jul 20, 2010
Messages
3
That works :)

Btw is there anyway to when the oldest file in the folder was created?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,920
Messages
5,834,374
Members
430,281
Latest member
fabcat1

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
Top