I would like to select multiple files (as shown); eg. "DataSource Quality", "DataSource Security", "DataSource Shipping", "DataSource Warehouse".
To add on, if the file name selected is "DataSource Quality 2020", etc, it should still be a valid selection. Meaning to say, so long the filename contains the names as shown in the screenshot above, it should still be considered correct.
However, if any one of the files selected are wrong (wrong partial file name), there should be a message box that says "No/Wrong file selected".
Dim hasRun As Boolean
Sub RunOnlyOnce()
Application.DisplayAlerts = True
If hasRun = False Then
Dim fNameAndPath As Variant
fNameAndPath = Application.GetOpenFilename(FileFilter:="All Files (*.*), *.*", Title:="Select Files To Be Opened", MultiSelect:=True)
Debug.Print fNameAndPath
Debug.Print Dir(fNameAndPath)
If Dir(fNameAndPath) = "DataSource.xlsx" Then
Workbooks.Open Filename:=fNameAndPath
hasRun = True
Exit Sub
Else
MsgBox "No/Wrong file selected. ", vbExclamation, "Oops!"
ThisWorkbook.Saved = False
Application.Quit
End If
End If
End Sub