LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default create a file list from a folder?

Press Alt + F11 to open the Visual Basic Editor, click INSERT on the menu and
select MODULE. Paste the following Macro code into the module and modify the
value for strPath from "H:\Excel" to whatever drive and folder you're looking
in:

Sub MyDirFiles()

Dim wb As Workbook
Dim ws As Worksheet
Dim strPath As String
Dim strDir As String
Dim lngRowOffset As Long
Dim strFiledate As String
Dim strFileTime As String
Dim strFileDateTime As String

Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1")

strPath = "H:\Excel" "Chcnge this value to your path
strDir = Dir(strPath & "\*.*")

Do While strDir < ""
With ws.Range("A1")
.Offset(lngRowOffset).Value = strDir
strFileDateTime = _
FileDateTime(strPath & "\" & strDir)
.Offset(lngRowOffset, 1).Value = _
Left$(strFileDateTime, _
InStr(1, strFileDateTime, " ") - 1)
.Offset(lngRowOffset, 2).Value = _
Right$(strFileDateTime, _
Len(strFileDateTime) - _
InStr(1, strFileDateTime, " "))
End With
lngRowOffset = lngRowOffset + 1
strDir = Dir
Loop

Set wb = Nothing
Set ws = Nothing

End Sub

Save and close the VBE and run it from Excel by clicking TOOLS/MACRO/MACROS
and selecting MyDirFiles from the list.
--
Kevin Backmann


"Hal239" wrote:

How do I create a detailed list of files in a directory, with date created,
modified, etc?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you create file folder labels in excel? rebecca_vsp New Users to Excel 2 May 16th 08 02:00 AM
can I create backup file in separate folder from the original? MCC Wong Setting up and Configuration of Excel 9 January 19th 08 01:06 AM
How to create a list of file names within a folder in Microsoft Ex Seablue Excel Discussion (Misc queries) 2 April 9th 07 08:44 PM
Create a copy in the same folder when a file is modified and saved Turboj Excel Discussion (Misc queries) 1 February 21st 06 04:51 AM
How do I Create backup of excel file in other folder khalid Excel Discussion (Misc queries) 1 May 24th 05 11:01 AM


All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"