Hello,
I have regularly use the workbook & worksheet combining macro below.
I was wondering if it would be possible to edit it in some way to make the macro only combine certain tabs that the user would specifiy the name of.
As an example, I have about 60 workbooks all containing 4 tabs and wish only to combine the tabs within each workbook called 'red report' is this possible??
Sub workbook_combine_actual()
'This will copy data from all sheets of the selected workbooks
'To a sheet named 'Data' in the sheet in which the macro is run from
Dim pasterow As String
mainsheetname = ActiveWorkbook.Name
MsgBox ("Please select spreadsheets to combine")
filestoopen = Application.GetOpenFilename(MultiSelect:=True)
responseval = MsgBox("Do you want to leave the combined spreadsheets open?", vbYesNo)
Worksheets("Data").Select
Range("A1").Select
'open workbooks
For Each w In filestoopen
Workbooks.Open Filename:=w
copysheetname = ActiveWorkbook.Name
'copy and paste sheets
For Each sh In Worksheets
sheetnumber = sh.Index
something = Worksheets(sheetnumber).UsedRange.Rows.Count + 1
Worksheets(sheetnumber).UsedRange.Copy
Workbooks(mainsheetname).Activate
pasterow = Workbooks(mainsheetname).Worksheets("Data").UsedRange.Rows.Count + 1
If pasterow = 2 Then
pasterow = 1
End If
Workbooks(mainsheetname).Worksheets(2).Range("A" & pasterow).Select
ActiveSheet.Paste
Workbooks(copysheetname).Activate
Next sh
If responseval = 7 Then
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End If
Next w
Workbooks(mainsheetname).Activate
End Sub
Thanks for taking the time to read through my query.
Bookmarks