Hi,
I have to Files (attached File A and B)
For each Project in File A, I need to search for the values in File B - by Project and by Week - and consolidate them into File A. The search for values should be done if it is the same Client and written on the row tagged Prévisionnel
The code I use:
Sub Prev()
Dim ws1 As Worksheet: Set ws1 = Workbooks("File A.xlsx").Worksheets("1")
Dim ws2 As Worksheet: Set ws2 = Workbooks("File B.xlsm").Worksheets("1")
Dim lRow As Long, i As Long, c As Long
lRow = ws1.Cells(Rows.Count, 1).End(xlUp).Row
For i = 11 To lRow
If ws1.Cells(i, 1).Value = "PCD" And ws1.Cells(i, 4).Value = "Prévisionnel" Then
For c = 7 To 66
On Error Resume Next
ws1.Cells(i, c).Value = _
WorksheetFunction.Index(ws2.Range("H11:BG28"), _
WorksheetFunction.Match(ws1.Cells(i, 3), ws2.Range("F11:F28"), 0), _
c - 7)
Next c
End If
Next i
End Sub
The issue is that a Project can be encounred on multiple rows on File B, but on a single row in File A. The value to be considered, in this case, should be the sum of values on those rows, by week.
The week number is noted in both Files on row 10 in this format: e.g. W5-1(Week5- January etc)
Many thanks for any support