Hello,
I' wrote the following code to copy values from one workbook and paste to another based on the previous day followed by averaging the previous day to the first day of the month. That works well with static ranges for instance a10 to previous day (a26). I have 3 nested For Each loops, one for finding the previous day in a range of days (same month), another For Each loop for the nine rows of data being copied to a workbook that houses nine equally spaced columns of cells, the third For Each loop jumps to the next block of cells. Each block of cells has a date column. My problem, the loop runs through completely once then continues. I may have the copy loop and jump to next block of cells loop in reverse order, Although i tried switching and it continues for the reverse number of counts. Below is my code, thanks in advance.
[VBA]Sub Copy_Paste_Deliveries2()
Proj_Dir = "H:\SOPUS Supply\Process Improvement Projects\"
Proj_Wb_1 = "Proj 0513 - JW Process Improvements.xlsm"
Proj_Wb = Proj_Dir & Proj_Wb_1
AllPages_Wb = "all pages.xlsm"
Workbooks.Open Proj_Wb
Dim QCell As Range
For i = 1 To 113 Step 14
For j = 2 To 9 Step 1
Set QCell = Workbooks(Proj_Wb_1).Worksheets("Sheet1").Range(Cells(10, i), Cells(40, i))
For Each Cell In QCell
If Cell = Date - 1 Then
Workbooks(AllPages_Wb).Worksheets("Reconsign").Cells(j, 11).Copy
Workbooks(Proj_Wb_1).Worksheets("Sheet1").Range(Cell.Address).Offset(0, 2).PasteSpecial Paste:=xlPasteValues
Workbooks(Proj_Wb_1).Worksheets("Sheet1").Range(Cell.Address).Offset(0, 2).Value = Workbooks(Proj_Wb_1).Worksheets("Sheet1").Range(Cell.Address).Offset(0, 2).Value
Application.CutCopyMode = False
r = Range(Cell.Offset(0, 2), Cells(10, i + 2))
Cell.Offset(1, 2) = Round(WorksheetFunction.Average(r), 0)
Cell.Offset(1, 2).AutoFill Destination:=Range(Cell.Offset(1, 2), Cells(40, i + 2)), Type:=xlFillDefault
End If
Next Cell
Next j
Next i
End Sub[/VBA]