MickG
Thanks for your interest and respons
The format set in my macro goes like this:
arFiles(2, cnt) = Format(file.DateLastAccessed, "yyyy.mm.dd hh:mm")
The cell value is like this:
2009.12.01 12:21
When I manually double-click the celle (like editing) - but not change anything - the celle format automatic turns over to be numeric.
- magic, but it wouldnt be necessary as long as the VBA could do the walk.
I want to get the possibility to sett filter on my files to show all files in my list accessed between to points of time.
I dont think (=my experience) that this filter option will work when AccessedDate is performed as text.
Regards with best wishes for your Christmas season
Snoopy
Here is the complete macro sequence that lists the files and shows the LastAccessedDates (please overlook the Norwegian fraces):
Sub Folders()
Application.DisplayAlerts = False
On Error Resume Next
Sheets("Files").Delete
If Err.Number <> 0 Then
On Error GoTo 0
End If
Dim Folder As String
'Folder = InputBox("Enter ønsket RadNr.")
Folder = 6
Folder = Trim(Folder)
Dim i As Long
Set FSO = CreateObject("Scripting.FileSystemObject")
arFiles = Array()
cnt = 0
level = 1
ReDim arFiles(3, 0)
'**********************************
' henter fra folder
'**********************************
arFiles(0, 0) = Worksheets(1).Range("A" & Folder)
'arFiles(0, 0) = GetFolder()
If arFiles(0, 0) <> "" Then
'res = InputBox("Please enter an extension" & _
" to search for in the format'.nwd'")
res = ThisWorkbook.Worksheets("Board").Range("A8").Value
res = Trim(res)
arFiles(1, 0) = level
SelectFiles arFiles(0, 0)
Worksheets.Add.Name = "Files"
With ActiveSheet
.Cells(1, 1).Value = "Path"
.Cells(1, 2).Value = "FileName"
.Cells(1, 3).Value = "Accessed"
.Cells(1, 4).Value = "Size"
.Rows(1).Font.Bold = True
.Columns(4).NumberFormat = "#,##0 "" KB"""
cnt = 1
For i = LBound(arFiles, 2) To UBound(arFiles, 2)
.Cells(i + 2, 1).Value = arFiles(0, i)
.Cells(i + 2, 2).Value = arFiles(1, i)
.Cells(i + 2, 3).Value = arFiles(2, i)
.Cells(i + 2, 4).Value = arFiles(3, i) / 1024
' alttaki satýr badmin e ait.
ActiveSheet.Hyperlinks.Add _
Anchor:=.Cells(i + 2, 2), _
Address:=arFiles(0, i) & "\" & arFiles(1, i)
Next
.Columns("A:D").EntireColumn.AutoFit
End With
End If
Application.DisplayAlerts = True
End Sub
'-----------------------------------------------------------------------
Sub SelectFiles(ByVal sPath)
'-----------------------------------------------------------------------
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object
Set Folder = FSO.GetFolder(sPath)
Set Files = Folder.Files
For Each file In Files
If (file.Attributes And 2 Or _
file.Attributes And 4) Then
'
Else
If InStr(1, file.Name, res, vbTextCompare) > 0 Then
cnt = cnt + 1
ReDim Preserve arFiles(3, cnt)
arFiles(0, cnt) = Folder.path
arFiles(1, cnt) = file.Name
arFiles(2, cnt) = Format(file.DateLastAccessed, "yyyy.mm.dd hh:mm")
arFiles(3, cnt) = file.Size
End If
End If
Next file
level = level + 1
For Each fldr In Folder.Subfolders
SelectFiles fldr.path
Next
End Sub