Replace with this amended macro
Sub Test()
Range(Cells(2, 4), Cells(65536, 5)).Clear
For N = 21 To 51
If Cells(2, 1) = 2 And N >= 50 Then Exit For
If Day(DateSerial(Cells(2, 2), Cells(2, 1), N)) <> 21 Then
Cells(65536, 4).End(xlUp).Offset(1, 0) = DateSerial(Cells(2, 2), Cells(2, 1), N)
ElseIf N = 21 Then
Cells(65536, 4).End(xlUp).Offset(1, 0) = DateSerial(Cells(2, 2), Cells(2, 1), N)
End If
Select Case Weekday(DateSerial(Cells(2, 2), Cells(2, 1), N))
Case Is = 1
Cells(65536, 4).End(xlUp).Offset(0, 1) = "Sunday"
Case Is = 2
Cells(65536, 4).End(xlUp).Offset(0, 1) = "Monday"
Case Is = 3
Cells(65536, 4).End(xlUp).Offset(0, 1) = "Tuesday"
Case Is = 4
Cells(65536, 4).End(xlUp).Offset(0, 1) = "Wednesday"
Case Is = 5
Cells(65536, 4).End(xlUp).Offset(0, 1) = "Thursday"
Case Is = 6
Cells(65536, 4).End(xlUp).Offset(0, 1) = "Friday"
Case Is = 7
Cells(65536, 4).End(xlUp).Offset(0, 1) = "Saturday"
End Select
Next N
End Sub
Bookmarks