GetOpenFileName show parth of name

Hermanie

Board Regular
Joined
Nov 28, 2016
Messages
56
Hi all,

I'm using application.getopenfilename to select multiple files from a directory. However, the directory holds 1000+ files and I only need the ones with the string "valuations" in it. So for example I need the files 20180108-Valuations, 20180518-Valuations etcetera. To make life easier I was hoping that I can define this "*valuations" part via the application.getopenfilename line.

Current line: Application.GetOpenFilename("Excel workbooks, *.xls", MultiSelect:=True)

Is there a way to have this added to the line?

Thanks in advance excel warriors!

Frank
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Not possible with Application.GetOpenFilename, but can be done with Application.FileDialog(msoFileDialogOpen).

Code:
Public Sub Select_Files()

    Dim i As Long
   
    With Application.FileDialog(msoFileDialogOpen)
        .Title = "Select files"
        .InitialFileName = "C:\folder\path\*valuations.xls"
        .AllowMultiSelect = True
        .Filters.Clear        
        If .Show Then
            'Display selected files
            For i = 1 To .SelectedItems.Count
                MsgBox .SelectedItems(i)
            Next
        Else
            MsgBox "Cancelled"
        End If        
    End With
        
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top