Hi, in my Macro I have added a FileDialog popup for users to select a file.
However, sometimes the subfolders contain a lot of files. I would like to narrow down the number of files visible to reduce the likelihood of a user selecting the wrong file.
Is it possible for me to add a line to the FileDialog to only show files containing certain text?
For example, suppose my files were named by a specific month and I only wanted to see files containing *Sep* to show only the September files, is this something you are able to do within VBA?
Currently I have added a Title and Initial file name to help the user, but this is still open to error.
However, sometimes the subfolders contain a lot of files. I would like to narrow down the number of files visible to reduce the likelihood of a user selecting the wrong file.
Is it possible for me to add a line to the FileDialog to only show files containing certain text?
For example, suppose my files were named by a specific month and I only wanted to see files containing *Sep* to show only the September files, is this something you are able to do within VBA?
Currently I have added a Title and Initial file name to help the user, but this is still open to error.
VBA Code:
Dim fd As FileDialog
Dim SepData As Workbook
Dim lastRow As Long
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
.Filters.Clear
.Title = "Select Sep Data"
.AllowMultiSelect = False
.InitialFileName = "Sep Data"
If .Show Then Set SepData = Workbooks.Open(.SelectedItems(1))
.Execute
End With