The Monday of the previous week with VBA

  • Thread starter Gérard Ducouret
  • 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
 
B

Bob Phillips

=A1-WEEKDAY(A1,2)+1

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Joined
Jul 24, 2015
Messages
1
Reaction score
0
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
 

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