Possibly...
Option Explicit
Sub Test()
Dim PathToFiles As String, AllFileNames As Variant, FileName As Variant
'Pick folder with files
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
If .SelectedItems.Count = 0 Then Exit Sub
PathToFiles = .SelectedItems(1) & Application.PathSeparator
End With
' or use
'PathToFiles = "your file path" & Application.PathSeparator
AllFileNames = GetFiles(PathToFiles, "xlsx") 'change or remove extention
For Each FileName In AllFileNames
Workbooks.Open (PathToFiles & FileName)
Call refresh
Workbooks(FileName).Close SaveChanges:=True
Next FileName
End Sub
Function GetFiles(sPath As String, Optional Ext As String) As Variant
Dim sFileName As String
With CreateObject("Scripting.Dictionary")
If Len(Ext) = 0 Then
Ext = "*.*"
Else
Ext = "*." & Ext
End If
sFileName = Dir(sPath & Ext, vbNormal)
Do While Not sFileName = vbNullString
.Item(sFileName) = Empty
sFileName = Dir
Loop
GetFiles = .keys
End With
End Function
Bookmarks