HI Guys,
Thanks to mikeTRON, I've got a macro to copy all the tabs in from another workbook which is achieved by navigating to that workbook (see below). However, I forgot to ask for a code that does the will take the filename of the source workbook (without the extension) and put it into cell C2 of the "Welcome" tab in the destination workbook.
Can anyone help please?
Thanks
Sub ImportSheets()
'Declare Vaiables
Dim filePathandName As Variant
Dim filename As String
Dim sheet As Worksheet
Dim total As Integer
'Setup VBA for SPEED
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'Define File and path
filePathandName = Application.GetOpenFilename("Excel Files (*.xl*), *.xl*", Title:="************ Select File to Import ************")
If filePathandName <> False Then
Workbooks.Open (filePathandName)
filename = ActiveWorkbook.Name
'Do Work
For Each sheet In Workbooks(filename).Worksheets
total = ThisWorkbook.Worksheets.Count
Workbooks(filename).Worksheets(sheet.Name).Copy _
after:=ThisWorkbook.Worksheets(total)
Next sheet
'Close the workbook
Workbooks(filename).Close (False) 'Save the workbook without saving it
End If
'End Macro
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Bookmarks