Solved: Calculate xth day of month

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Pedro15

Thread Starter
Joined
Oct 5, 2008
Messages
386

Attachments

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,612
I did not look at your files, just want to give you this.

I found this code a long time ago and have been using it since.

This formula will return the date of any day of the week you enter

Code:
' We can generalize this to holidays that are defined as the Nth Day of some month,
' such as Martin Luther King's birthday, celebrated on the 3rd Monday of January.
' The following function will return the Nth DayOfWeek for a given month and year:
'SYntax NDOW:
'   y = Year
'   M = Month
'   N = Nth day of M month
'   DOW = Day of the week:  1 = Sunday, 2= Monday, etc.
Public Function NDow(Y As Integer, M As Integer, N As Integer, DOW As Integer) As Date
    NDow = DateSerial(Y, M, (8 - WeekDay(DateSerial(Y, M, 1), (DOW + 1) Mod 8)) + ((N - 1) * 7))
End Function
The comments in the code are form the original code and should explain itsself
 

Pedro15

Thread Starter
Joined
Oct 5, 2008
Messages
386
Hans,
Thanks for that though I am not that much savvy with macros so will try and struggle though it tomorrow.
In the meantime if someone can explain where I have gone wrong with my attempt it would be appreciated

Pedro
 

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,612
I'll take a look and see if I can find it.
I will also implement the code I posted to see if it helps you
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top