Hi Experts,
I have code which is doing consolidation of all spreadsheet to master sheet.
I want to exclude one sheet say “Project 2”, while consolidation “Project 2” data / or sheet require to excluding.
I am attaching code for your reference.
Illustration fill is attached for your ready reference.
Thanks in advance
Amar K
Sub ConsolidateSheets()
Dim ms As Worksheet, ws As Worksheet, LR As Long, i As Long, NR&
Application.ScreenUpdating = 0
Application.DisplayAlerts = 0
On Error Resume Next
If Not Evaluate("ISREF('Master'!A1)") Then
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Master"
Else
Sheets("Master").Range("A2:M" & Rows.Count).ClearContents
End If
Set ms = Sheets("Master")
For Each ws In ActiveWorkbook.Sheets
With ws
If .Name <> ms.Name Then
LR = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
NR = ms.Cells.Find("*", , , , xlByRows, xlPrevious).Row + 1
.Range("A2:L" & LR).Copy
ms.Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlValues
ms.Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(LR - 1) = ws.Name
End If
End With
Next
Application.CutCopyMode = 0
ms.Columns.EntireColumn.AutoFit
Set ms = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Bookmarks