Hello - I am studying VBA language. I am stuck. I want data from each of these sheets to be copied to the IMPROPER DETAIL tab but I can't get it to work. Can you tell me what I am missing?
Sub updatedatafromsheets()
Dim LoopCounter As Integer
Dim NumberOfWorksheets As Integer
Dim lastrow As Long
Dim erow As Long
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
NumberOfWorksheets = Worksheets.Count
For LoopCounter = 1 To NumberOfWorksheets
erow = Sheets("IMPROPER DETAIL").Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
For i = 20 To lastrow
Sheets("QTR1").Cells(i, 3).Copy
Sheets("QTR1").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR1").Cells(i, 4).Copy
Sheets("QTR1").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR1").Cells(i, 5).Copy
Sheets("QTR1").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Sheets("QTR2").Cells(i, 3).Copy
Sheets("QTR2").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR2").Cells(i, 4).Copy
Sheets("QTR2").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR2").Cells(i, 5).Copy
Sheets("QTR2").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Sheets("QTR3").Cells(i, 3).Copy
Sheets("QTR3").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR3").Cells(i, 4).Copy
Sheets("QTR3").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR3").Cells(i, 5).Copy
Sheets("QTR3").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Sheets("QTR4").Cells(i, 3).Copy
Sheets("QTR4").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR4").Cells(i, 4).Copy
Sheets("QTR4").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR4").Cells(i, 5).Copy
Sheets("QTR4").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Next i
Next LoopCounter
Application.CutCopyMode = False
Worksheets("IMPROPER DETAIL").Columns.AutoFit
Range("A6").Select
End Sub
Sub updatedatafromsheets()
Dim LoopCounter As Integer
Dim NumberOfWorksheets As Integer
Dim lastrow As Long
Dim erow As Long
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
NumberOfWorksheets = Worksheets.Count
For LoopCounter = 1 To NumberOfWorksheets
erow = Sheets("IMPROPER DETAIL").Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
For i = 20 To lastrow
Sheets("QTR1").Cells(i, 3).Copy
Sheets("QTR1").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR1").Cells(i, 4).Copy
Sheets("QTR1").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR1").Cells(i, 5).Copy
Sheets("QTR1").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Sheets("QTR2").Cells(i, 3).Copy
Sheets("QTR2").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR2").Cells(i, 4).Copy
Sheets("QTR2").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR2").Cells(i, 5).Copy
Sheets("QTR2").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Sheets("QTR3").Cells(i, 3).Copy
Sheets("QTR3").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR3").Cells(i, 4).Copy
Sheets("QTR3").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR3").Cells(i, 5).Copy
Sheets("QTR3").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Sheets("QTR4").Cells(i, 3).Copy
Sheets("QTR4").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)
Sheets("QTR4").Cells(i, 4).Copy
Sheets("QTR4").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 4)
Sheets("QTR4").Cells(i, 5).Copy
Sheets("QTR4").Paste Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 5)
Next i
Next LoopCounter
Application.CutCopyMode = False
Worksheets("IMPROPER DETAIL").Columns.AutoFit
Range("A6").Select
End Sub