# FileDialog to only show xlsx files containing certain text



## j4ttlife (Dec 23, 2022)

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. 


```
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
```


----------



## Fluff (Dec 23, 2022)

Change the initial file name to "*sep*"


----------



## j4ttlife (Dec 23, 2022)

Fluff said:


> Change the initial file name to "*sep*"


Perfect, thank you


----------



## Fluff (Dec 23, 2022)

You're welcome & thanks for the feedback.


----------

