Good morning,
I am running the following code..I Know its crude but mostly it works, however on one of the sheets it misses a few weeks out when searching where i is = 2,4,6,8 but picks the person up again when i is = 10,12 and 14.....any ideas...for the rest of the worksheets it seems to be fine but i am still checking
I am running the following code..I Know its crude but mostly it works, however on one of the sheets it misses a few weeks out when searching where i is = 2,4,6,8 but picks the person up again when i is = 10,12 and 14.....any ideas...for the rest of the worksheets it seems to be fine but i am still checking
Code:
Sub BringWeek()
Dim sh As Worksheet
Dim NextRow As Integer
Range("A11:O29").ClearContents
Application.ScreenUpdating = False
Dat = Worksheets("Holidays").Cells(5, 1).Value
NextRow = 11
For y = 3 To 53
For x = 2 To 14 Step 2
For i = 5 To 57
Worksheets(y).Activate
If Cells(i, x) = "H" And Cells(i, 1) = Dat Then
Worksheets("Holidays").Cells(NextRow, 2).Value = Cells(i, 2)
Worksheets("Holidays").Cells(NextRow, 4).Value = Cells(i, 4)
Worksheets("Holidays").Cells(NextRow, 6).Value = Cells(i, 6)
Worksheets("Holidays").Cells(NextRow, 8).Value = Cells(i, 8)
Worksheets("Holidays").Cells(NextRow, 10).Value = Cells(i, 10)
Worksheets("Holidays").Cells(NextRow, 12).Value = Cells(i, 12)
Worksheets("Holidays").Cells(NextRow, 14).Value = Cells(i, 14)
Worksheets("Holidays").Cells(NextRow, 1).Value = Cells(1, 4)
y = y + 1
NextRow = NextRow + 1
End If
Next i
Next x
Next y
Application.ScreenUpdating = True
End Sub