Hi everyone, I'm hoping that someone can help me with a problem I've got.
I am trying to get a message box to appear if a check in date is a Thursday, Friday, Saturday or a Sunday, and have set up an IF fuction in VBA, however it never works.
However, if a date, for example the 15th March (Tuesday) is the checkindate, the message box always appear. This should only appear if the checkindate is Sunday, Thursday, Friday or Saturday.
HELP please
Many thanks in advance.
I am trying to get a message box to appear if a check in date is a Thursday, Friday, Saturday or a Sunday, and have set up an IF fuction in VBA, however it never works.
Code:
'declarations
Dim counter As Integer
Dim checkindate As Date
counter = Cells(1, 16).Value
checkindate = Cells(counter, 4).Value
If Weekday(checkindate) = 1 Then daytext1 = "Sunday"
If Weekday(checkindate) = 2 Then daytext1 = "Monday"
If Weekday(checkindate) = 3 Then daytext1 = "Tuesday"
If Weekday(checkindate) = 4 Then daytext1 = "Wednesday"
If Weekday(checkindate) = 5 Then daytext1 = "Thursday"
If Weekday(checkindate) = 6 Then daytext1 = "Friday"
If Weekday(checkindate) = 7 Then daytext1 = "Saturday"
If Weekday(checkindate) = 1 Or 5 Or 6 Or 7 Then
MsgBox (daytext1)
Else
MsgBox ("seems to work")
Exit Sub
End If
However, if a date, for example the 15th March (Tuesday) is the checkindate, the message box always appear. This should only appear if the checkindate is Sunday, Thursday, Friday or Saturday.
HELP please
Many thanks in advance.