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
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

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?
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,925
Messages
5,514,200
Members
408,990
Latest member
fresse68

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top