Macro - Copy from Multiple Worksheets and Paste to Multiple Worksheets

Exc123

New Member
Joined
Apr 5, 2006
Messages
38
Good evening! I have 2 separate workbooks, each with 120 worksheets. Each workbook has the same exact set of worksheet names with the only difference being each file is a different year. I would like to combine each of these worksheets so that Workbook 2>Worksheet 1 is copied and pasted to the end of the text on Workbook 1>Worksheet 1 then Workbook 2>Worksheet 2 is copied and pasted to the end of the text on Workbook 1>Worksheet 2. I need this to go through all 120 and I'm not even sure where to start.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Sorry for posting again so soon. I forgot to paste my current code. I'm not sure how to take the wb1.sheets() portion and make it loop 1 through 120.

Code:
Sub Test()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim WS As Worksheet
Set wb1 = Workbooks("2009 NCAA Results")
Set wb2 = Workbooks("2010 NCAA Results")
For Each WS In wb1.Worksheets
   If WS.Name = wb1.Sheets(1).Name Then
      WS.Range("$A$4:$P$19").Copy Destination:=wb2.Sheets(1).Range("$A$20")
   End If
Next
End Sub
 
Upvote 0
Solved.

Code:
Sub Test()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim WS As Worksheet
Dim i As Integer
Set wb1 = Workbooks("2009 NCAA Results")
Set wb2 = Workbooks("2010 NCAA Results")
For i = 1 To 120
For Each WS In wb1.Worksheets
   If WS.Name = wb1.Sheets(i).Name Then
      WS.Range("$A$4:$P$19").Copy Destination:=wb2.Sheets(i).Range("$A$20")
   End If
Next
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,629
Members
452,933
Latest member
patv

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