The below code is lengthy when comparing to JBeaucaire's code. But me too tried to get solution for your query and spent some time in writing the below code. So posting the code even though you got the shorter code.
Option Explicit
Sub ConsolidateData()
Dim mSh As Worksheet, i As Byte, LRw As Long
Dim arrSh() As Worksheet, shFound As Boolean
Dim UsrSel As Byte, CursrLoc As Range
ReDim arrSh(1 To 5)
Set arrSh(1) = Sheets("01")
Set arrSh(2) = Sheets("02")
Set arrSh(3) = Sheets("03")
Set arrSh(4) = Sheets("04")
Set arrSh(5) = Sheets("05")
For i = 1 To Sheets.Count
If Sheets(i).Name = "Summary" Then
shFound = True
Exit For
End If
Next i
If shFound Then
UsrSel = MsgBox("Summary Sheet Already Exist." _
& "Do you want to replace it with New Sheet?" _
, vbQuestion + vbYesNo + vbDefaultButton2, "Sheet Exist")
If UsrSel = 6 Then
Application.DisplayAlerts = False
Sheets("Summary").Delete
Application.DisplayAlerts = True
Else
MsgBox "Unable to continue, since sheet already exist"
Application.ScreenUpdating = True
Exit Sub
End If
End If
Application.ScreenUpdating = False
Sheets.Add Before:=Sheets(1)
ActiveSheet.Name = "Summary"
Set mSh = ActiveSheet
For i = 1 To UBound(arrSh())
arrSh(i).Select
Set CursrLoc = ActiveCell
Range("A3:A" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Selection.Copy
CursrLoc.Select
mSh.Select
LRw = Cells(Rows.Count, "A").End(xlUp).Row
Cells(LRw + 1, "A").Select
Selection.PasteSpecial xlPasteAll
arrSh(i).Select
Set CursrLoc = ActiveCell
Range("AM3:AM" & Cells(Rows.Count, "AM").End(xlUp).Row).Select
Selection.Copy
CursrLoc.Select
mSh.Select
LRw = Cells(Rows.Count, "AM").End(xlUp).Row
Cells(LRw + 1, "AM").Select
Selection.PasteSpecial xlPasteAll
Range("A3").Select
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
Bookmarks