Hi
I am trying to take all of data from different sheets to master sheet (Append). I am very beginner to Excel VBA. I have written the following code but it does't loop through all the sheets. Can anyone help me out.
Thanks in advance
I am trying to take all of data from different sheets to master sheet (Append). I am very beginner to Excel VBA. I have written the following code but it does't loop through all the sheets. Can anyone help me out.
Thanks in advance
Code:
Sub Copypastemaster()
Dim Lrow As Long, MLR As Long, ws As Worksheet
MasterLR = Sheets("Append").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
'ws =1 to Sheets.Count - 1
'Lrow = ws.Cells(Rows.Count, 1).End(xlDown).Row
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Append" Then
Lrow = ws.Cells(Rows.Count, 1).End(xlDown).Row
'If MLR = 0 Then
ws.Range(ws.Cells(2, 1), ws.Cells(Lrow, 5)).Copy
'Selection.Copy
'Sheets("Append").Cells(MasterLR, 1).Select
Sheets("Append").Range("A" & MasterLR).PasteSpecial xlPasteValues
'Else
'ws.Range("B3:F" & lrow).Copy Destination:=MasterWs.Range("B" & MLR)
End If
'MLR = (Append.Range("B2").Rows.End(xlDown).Row) + 1
'End If
Next ws
End Sub
Attachments
Last edited by a moderator: