I have a code I have pieced together. The goal is to take all the excel files in a folder, open them up and add the sheets together to form a pivot table. I can easily set a path = 'foldername' and it works, however, I was wanting to make it to where I could just browse for the folder instead and have the path reference the chosen path from the msoFileDialogFolderPicker. I know that the path=Diafolder is incorrect and am looking for an answer to this. Thank you ahead of time.
Dim Diafolder As FileDialog
Dim path As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
' Open the file dialog
Set Diafolder = Application.FileDialog(msoFileDialogFolderPicker)
Diafolder.AllowMultiSelect = False
Diafolder.Show
Msgbox Diafolder.SelectedItems(1)
Set Diafolder = Nothing
path = Diafolder
fileName = Dir(path & "*.xls")
Do While fileName <> ""