Copy/paste same range from multiple workbooks into different worksheets in another workbook

Lizard07

Board Regular
Joined
Jul 20, 2011
Messages
103
Hi - I'm trying to have this code open up the workbooks (one by one) in this file location, copy range B2 through L100 into B6 through B100 in its corresponding worksheet in the activeworkbook. For instance, open "Aberdeen" and copy the data into the "Aberdeen" worksheet.

The code below currently copies the Aberdeen workbook data into both the Aberdeen and Birmingham sheets...please advise. Thanks!

Sub Create_Month_Summary()
Dim folderPath As String
Dim fileName As String
Dim thisWorkbook As Workbook
Dim dayNumber As Integer
Dim workbookDate As Date
Dim rowOffset As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False

'Folder containing daily dated workbooks for a month - CHANGE AS REQUIRED

folderPath = "P:\PROJECT\DAN\Utilization Reports"

Set thisWorkbook = ActiveWorkbook

If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"

rowOffset = 0
fileName = Dir(folderPath & "*.xls")

'Copy data from dated workbook to associated row in summary sheet

Workbooks.Open folderPath & fileName

With thisWorkbook.Sheets("Aberdeen").Range("B2:L100")
.Offset(rowOffset, 0).Value = Sheets("Sheet1").Range("B5:L100").Value
End With
ActiveWorkbook.Close savechanges:=False

Workbooks.Open folderPath & fileName

With thisWorkbook.Sheets("Birmingham").Range("B2:L100")
.Offset(rowOffset, 0).Value = Sheets("Sheet1").Range("B5:L100").Value
End With
ActiveWorkbook.Close savechanges:=False

MsgBox "Finished"

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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