The Monday of the previous week with VBA

  • Thread starter Thread starter Gérard Ducouret
  • Start date Start date
G

Gérard Ducouret

Hello,

I have a date from Monday to Friday in the current week. I need to calculate
the date of the Monday of the previous week in VBA.
How can I do that ?
Thanks a lot

Gérard
 
=A1-WEEKDAY(A1,2)+1

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Hello,

I have a date from Monday to Friday in the current week. I need to calculate
the date of the Monday of the previous week in VBA.
How can I do that ?
Thanks a lot

Gérard

You can modify this code for your particular use and many others:

For i = 1 To 7
findDay=DateAdd("d",i,Date)
if Weekday(findDay)=2 then
Response.Write "<br />" & findDay &" Mon"
EXIT for
end if
Next

Just change the 2 in above to the day of week you want, change it's value of the day of week from plus to minus, i.e. 2 or -2 ... if you want next or prior.
glm
 
Back
Top