Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Date checking

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Date checking

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

"Johnny" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Date checking

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
-----Original Message-----
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

"Johnny" wrote in

message
...
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



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking a date/number between two others [email protected] Excel Discussion (Misc queries) 6 March 31st 09 12:01 AM
Color Code Date Checking drvortex Excel Worksheet Functions 3 February 1st 06 07:34 AM
checking what day a date is? neowok[_67_] Excel Programming 5 June 24th 04 12:41 PM
Help with Date checking code Mr. Clean[_2_] Excel Programming 2 February 20th 04 03:24 PM
Checking for valid date Paul M.[_3_] Excel Programming 4 December 1st 03 07:25 PM


All times are GMT +1. The time now is 02:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"