Date checking

  • Thread starter Thread starter Johnny
  • Start date Start date
J

Johnny

Hi,

How to check that the date of the particular month is the
2nd sunday of the week. for example the date must be 10th
and it is the 2nd sunday of the week? How to code in VBA?

MANY THANKS.

regards,
Johnny
 
I'm not sure where your source data is coming from, but the following code
tests to see if an input date is the second Sunday of the month (I hope you
wanted the second Sunday of the month instead of the second Sunday of the
week <g>).

Sub Check_Date()

Dim InputDate As Date

InputDate = InputBox("Enter Date")

If Weekday(InputDate) = 1 And Day(InputDate) > 7 And Day(InputDate) < 15
Then
MsgBox InputDate & " is the second Sunday of the month."
Else
MsgBox InputDate & " is not the second Sunday of the month."
End If

End Sub


HTH

--
Michael J. Malinsky
Pittsburgh, PA

"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh
 
Hi,

Thanks. Is it possible to check in advance the date so
that another macro can be triggered? Can it also be find
the date of the month?

regards,
Johnny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top