Calulating the last sayurday of a week using vba

  • Thread starter Thread starter ibeetb
  • Start date Start date
I

ibeetb

I am trying to write a formula, using vba to give me the date of the last
saturday from 'Today's date'. For example, if today is Monday, what is the
date of last saturday....

Any ideas?
 
Assume the date you're using as the start point is stored
in variable x, then:

y = x - (weekday(x) + 1)

will give you last Saturday's date in y, assuming you
haven't changed the FirstDayofWeek constant from Sunday.

Cheers, Pete
 
Hi, Pete:

Your code as written gives ME the previous Friday, not Saturday. You don't want to add 1 here.
i.e. it should be just

y = x - Weekday(x)

Myrna Larson
 

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

Back
Top