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
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