Hi, I want to check if the value of certain cells is equal to one of the dates in sheet 2, named "holiday", and then input certain characters in them.
I provided a sample, in which case the code only checks if the cells in sheet 1 are equal to sheet 2, cells A2 and A3; how can I write a better code where it would check all my named range ( "Holiday" in sheet 2)? Thanks
Sub test()
Dim i As Integer
Dim j As Variant
Sheet1.Select
For i = 0 To 2
j = 2 + (6 * i)
Cells(5, j) = "x"
Cells(5, j + 1) = "A"
If Cells(4, j + 2).Value = Sheet2.Cells(2, 1) Or Cells(4, j + 2).Value = Sheet2.Cells(3, 1) Or Weekday(Cells(4, j + 2), vbMonday) > 5 Then
Cells(5, j + 2) = "-"
Else
Cells(5, j + 2) = "o"
End If
Cells(5, j + 3) = "o"
Cells(5, j + 4) = "o"
Cells(5, j + 5) = "o"
Next i
End Sub
Bookmarks