Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sorting dates | Excel Discussion (Misc queries) | |||
sorting dates | Excel Discussion (Misc queries) | |||
Sorting dates | Excel Discussion (Misc queries) | |||
Sorting Dates | Excel Discussion (Misc queries) | |||
sorting using dates | Excel Discussion (Misc queries) |