Check overlap sunday/weekend

N

newbie

Hi,

I have a query on the overlap sunday for last week of sunday/weekend
and first week sunday/weekend.

For example, 30th June 2007 is considered last week of sunday/weekend
and I have tasks: XYZ that need to exceute it. But on 1st July 2007,
it is considered as first sunday/weekend and I have another tasks: ABC
to run on this date.

Please advise on how to check this using vba.

Thanks.

regards,
newbie
 
B

Bob Phillips

Maybe

=IF(AND(WEEKDAY(date_cell)=7,MONTH(date_cell)<>MONTH(Date_cell+1)), ... for
the Sat and


=IF(AND(WEEKDAY(date_cell)=1,MONTH(date_cell-1)<>MONTH(Date_cell)), ... for
the Sun

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
N

newbie

Maybe

=IF(AND(WEEKDAY(date_cell)=7,MONTH(date_cell)<>MONTH(Date_cell+1)), ... for
the Sat and

=IF(AND(WEEKDAY(date_cell)=1,MONTH(date_cell-1)<>MONTH(Date_cell)), ... for
the Sun

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)









- Show quoted text -

Hi,

Thanks. How about coding using vba?

regards,
Newbie
 
B

Bob Phillips

Dim myDate As Date
Dim LastWeek As Boolean
Dim FirstWeek As Boolean

myDate = DateSerial(2007, 6, 30)
LastWeek = Weekday(myDate) = 7 And Month(myDate) <> Month(myDate + 1)
FirstWeek = Weekday(myDate) = 1 And Month(myDate - 1) <> Month(myDate +
1)
MsgBox "Date " & myDate & ": " & vbNewLine & _
vbTab & "Firstweek = " & FirstWeek & vbNewLine & _
vbTab & "Lastweek = " & LastWeek

myDate = DateSerial(2007, 7, 1)
LastWeek = Weekday(myDate) = 7 And Month(myDate) <> Month(myDate + 1)
FirstWeek = Weekday(myDate) = 1 And Month(myDate - 1) <> Month(myDate +
1)
MsgBox "Date " & myDate & ": " & vbNewLine & _
vbTab & "Firstweek = " & FirstWeek & vbNewLine & _
vbTab & "Lastweek = " & LastWeek

myDate = Date
LastWeek = Weekday(myDate) = 7 And Month(myDate) <> Month(myDate + 1)
FirstWeek = Weekday(myDate) = 1 And Month(myDate - 1) <> Month(myDate +
1)
MsgBox "Date " & myDate & ": " & vbNewLine & _
vbTab & "Firstweek = " & FirstWeek & vbNewLine & _
vbTab & "Lastweek = " & LastWeek


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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

Top