Copying Specific Column Data From Many Worksheets Into a New Worksheet

CoraG

New Member
Joined
Aug 30, 2018
Messages
31
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
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hello,

You can test :

Code:
[COLOR=#333333]Sheets("QTR1").Cells(i, 3).Copy [/COLOR][COLOR=#333333]Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)[/COLOR]

HTH
 
Upvote 0
Nope.. It didn't work. It doesn't copy paste

Sub testcopypaste()
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

Worksheets("QTR1").Activate

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 Destination:=Sheets("IMPROPER DETAIL").Cells(erow, 2)

Next i

Next LoopCounter

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top