Harpreet Singh
New Member
Hi Experts,
i want to make a simple compiler to copy data from all the sheets to sheet4. i found an error in the following code.
Please help in finding the error. sample workbook is attached.
i want to make a simple compiler to copy data from all the sheets to sheet4. i found an error in the following code.
Code:
Sub Complier()
Dim ws As Worksheet
Dim lst1 As Integer
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Sheet4" Then
lst1 = ws.Range("A" & Rows.Count).End(xlUp).Row
ws.Range(Range("A2"), Range("" & lst1)).Copy Destination:=Sheet4.Range("A"& Rows.Count).End(xlUp).Offset(1,0)
End If
Next ws
End Sub
Please help in finding the error. sample workbook is attached.