Hello, I have this code below that copies data from all worksheets and copies it into one consolidated tab. My question is: is it possible to maintain a list on another tab called "List" and only select those worksheets that are part of that List to copy and consolidate data? Let us say I have 5 worksheets but I only want to copy and consolidate data from 2 of those called List 1 and List2 which are values maintained in tab called List? Thanks much!
Sub Consolidate()
Dim i As Integer
Dim w As Worksheet
On Error Resume Next
Sheets(1).Select
Worksheets.Add ' add a worksheet for consolidation of other tabs
Sheets(1).Name = "Consolidate"
' copy headings
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For Each w In ActiveWorkbook.Sheets
If w.Name <> "Consolidate" Then
Application.GoTo Sheets(w.Name).[a1]
Selection.CurrentRegion.Select
' Don't copy the headings
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets("Consolidate"). _
Cells(Rows.Count, 1).End(xlUp)(2)
End If
Next
End Sub
Sub Consolidate()
Dim i As Integer
Dim w As Worksheet
On Error Resume Next
Sheets(1).Select
Worksheets.Add ' add a worksheet for consolidation of other tabs
Sheets(1).Name = "Consolidate"
' copy headings
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For Each w In ActiveWorkbook.Sheets
If w.Name <> "Consolidate" Then
Application.GoTo Sheets(w.Name).[a1]
Selection.CurrentRegion.Select
' Don't copy the headings
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets("Consolidate"). _
Cells(Rows.Count, 1).End(xlUp)(2)
End If
Next
End Sub