I want to list filenames in a folder but exclude those with the text "Superseded".
Would it work using Instr?
Would it work using Instr?
Code:
Sub File_Attributes()
Dim sFolder As FileDialog
Set sFolder = Application.FileDialog(msoFileDialogFolderPicker)
If sFolder.Show = -1 Then
File_Attributes_List_Files sFolder.SelectedItems(1), True
End If
End Sub
Sub File_Attributes_List_Files(ByVal SourceFolderName As String, ByVal IncludeSubfolders As Boolean)
Dim FSO As Object
Dim SourceFolder As Object
Dim FileItem As Object
Dim strFile As String
Dim FileName As Variant
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FSO.GetFolder(SourceFolderName)
row = ActiveCell.row
With CreateObject("Scripting.Dictionary")
For Each FileItem In SourceFolder.Files
strFile = FileItem.Name
.Item(strFile) = Array(FileItem.Name)
Next FileItem
'Do While InStr(FileName, "") <> Superseded
For Each FileName In .Items
Cells(row, 3).Formula = FileName
row = row + 1
Next FileName
'Loop
End With
End Sub