Hi All,
I'm trying to build a VBA macro that will allow me to import a worksheet from up to three workbooks using a file picker.
Source workbooks will always have a sheet named "Monthly Summary", which I'd like to copy over
I have attempted to write the code below, but couldn't figure out how to do include the following:
1) Code needs to paste as values only (source worksheet has macros in it, which keeps getting copied along)
2) Code needs to paste to already existing sheets: "Monthly Summary 1", "Monthly Summary 2" and "Monthly Summary 3"
Any help is greatly appreciated.
Regards,
MBD
I'm trying to build a VBA macro that will allow me to import a worksheet from up to three workbooks using a file picker.
Source workbooks will always have a sheet named "Monthly Summary", which I'd like to copy over
I have attempted to write the code below, but couldn't figure out how to do include the following:
1) Code needs to paste as values only (source worksheet has macros in it, which keeps getting copied along)
2) Code needs to paste to already existing sheets: "Monthly Summary 1", "Monthly Summary 2" and "Monthly Summary 3"
VBA Code:
Sub ImportFiles()
Dim Qry As FileDialog
Dim FilePath, SheetName As String
Set Qry = Application.FileDialog(msoFileDialogFilePicker)
Qry.Title = "Select Files to Compare " & FileType
Qry.AllowMultiSelect = True
Qry.Filters.Clear
Qry.Show
If Qry.SelectedItems.Count = 1 Then
FilePath = Qry.SelectedItems(1)
End If
For i = 1 To Qry.SelectedItems.Count
Application.ScreenUpdating = False
Application.DisplayAlerts = False
FilePath = Qry.SelectedItems(1)
SheetName1 = "Monthly Summary"
Set wb2 = Workbooks.Open(FilePath)
wb2.Sheets(SheetName1).Copy After:=ThisWorkbook.Sheets(1)
Next i
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Any help is greatly appreciated.
Regards,
MBD