I am pretty new to VBA and am trying to get a macro running that will loop through all visible worksheets that do not include specific names ("Master", "Report")
Basically, I am wanting all used rows to be copied then inserted as new rows in sequence in the "Report" worksheet.
The code is only working for the first sheet, however there are two other worksheets visible that are named something different than above.
Any help is appreciated. Thank you.
Basically, I am wanting all used rows to be copied then inserted as new rows in sequence in the "Report" worksheet.
The code is only working for the first sheet, however there are two other worksheets visible that are named something different than above.
Any help is appreciated. Thank you.
VBA Code:
Public Sub ConsolidateData()
Dim lRow As Long
Dim lDestRow As Long
Dim DestWS As Worksheet
lRow = Cells(Rows.Count, "A").End(xlUp).Row
lDestRow = Sheets("Report").Cells(Rows.Count, "A").End(xlUp).Row
Set DestWS = Sheets("Report")
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Master" And ws.Visible <> False And ws.Name <> "Report" Then
With ws
Range("A1:z" & lRow).Copy DestWS.Rows(lDestRow)
End With
End If
Next ws
End Sub