LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Sorting dates

Eli,

Your code works fine, but you may have not seen anything because you increment your row counter
whether or not the file meets your requirement, so change

End If
r = r + 1 ' next row number

to

r = r + 1 ' next row number
End If

HTH,
Bernie
MS Excel MVP


"???" wrote in message
...
Hi!

I have found a function that imports a list of file names with its last
modification date (www.exceltip.com) and I have modified it so only files
with *.res extention will be imported. I want also to import only files that
was modified in the last 2 days but it not worked (see the code below). the
date is in the format of: dd/mm/yyyy hh:mm.

Sub ListFilesInFolder(SourceFolderName As String, IncludeSubfolders As
Boolean)
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
Dim t As Long
Dim s As Date
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
s = Now()
r = Range("A65536").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
t = s - FileItem.DateLastModified
If Right(FileItem.Name, 3) = "res" And t < 2 Then
Cells(r, 1).Formula = FileItem.Name
Cells(r, 2).Formula = FileItem.DateLastModified
End If
r = r + 1 ' next row number
Next FileItem
Columns("A:B").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub

I will be happy to understand what is wrong with it.

Thanks in advance

Eli



 
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
sorting dates Barry Excel Discussion (Misc queries) 1 August 21st 09 02:29 PM
sorting dates tommy Excel Discussion (Misc queries) 5 January 12th 09 01:52 AM
Sorting dates Goyo el Noyo Excel Discussion (Misc queries) 0 January 3rd 08 09:08 PM
Sorting Dates dah Excel Discussion (Misc queries) 3 March 23rd 06 03:34 PM
sorting using dates Tpason Excel Discussion (Misc queries) 1 January 14th 05 09:21 PM


All times are GMT +1. The time now is 03:10 AM.

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"