Hello all,
I need VBA code to search for a workbook and move its all sheets into current workbook by inserting them last.
I want format to be same as that of original file.
Below is the code i have developed but fails to meet my intent and returns error.
Please suggest me to with correct code.
Sub ImportData()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim Sh As Worksheet
Dim i As Integer
'Dim PasteStart As Range
Set wb1 = ActiveWorkbook
i = wb1.Worksheets.Count
'Set PasteStart = [Report!A1]
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a Report to Parse")
If FileToOpen = False Then
MsgBox "No File Specified.", vbExclamation, "ERROR"
Exit Sub
Else
Set wb2 = Workbooks.Open(Filename:=FileToOpen)
For Each Sh In wb2.Sheets
'ActiveSheet.Select
Sh.Copy After:=Workbooks(wb1).Sheets(i)
Next Sh
End If
wb2.Close
End Sub
Bookmarks