TryingtoLearnVBA
New Member
- Joined
- Jul 30, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
First Time Post Here.
I have two Workbooks one with daily data for the Month and one with shift data for the Month. Each of these workbooks has summation tabs at the beginning and end of the workbook. The ranges are not the same in the workbooks and there are twice as many sheets to copy to. The sheet names change on a monthly basis also.
I am trying to copy the data from the daily into the corresponding shift tab. What I have so far copy's the range from the daily into the 1st specified worksheet for the entire loop.
I am thinking I have the wrong approach to get this done. Any help would be appreciated and please let me know if I need to clarify more.
Thanks
I have two Workbooks one with daily data for the Month and one with shift data for the Month. Each of these workbooks has summation tabs at the beginning and end of the workbook. The ranges are not the same in the workbooks and there are twice as many sheets to copy to. The sheet names change on a monthly basis also.
I am trying to copy the data from the daily into the corresponding shift tab. What I have so far copy's the range from the daily into the 1st specified worksheet for the entire loop.
I am thinking I have the wrong approach to get this done. Any help would be appreciated and please let me know if I need to clarify more.
Thanks
VBA Code:
[
Option Explicit
Sub CopyData()
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim j As Integer
Dim i As Integer
Dim Filename1 As String
Filename1 = "JulyDailyData"
For i = 6 To 66 Step 2
For j = 2 To 32
Workbooks(Filename1).Worksheets(j).Range("J12:K26").Copy
ThisWorkbook.Worksheets(i).Range("Q11:R25").PasteSpecial Paste:=xlPasteValues
Next j
Next i
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub