Custom Functions Excel VBA

Thanks Giving Date
Floating dates for holidays like the thanks-giving holiday provide an opportunity to write an interesting custom function in Excel that can help us to find the date for the celebration for any year. Thanks-Giving falls on the 4th Thursday in November every year.
Public Function ThanksgivingDate(Yr As Integer) As Date
ThanksgivingDate = DateSerial(Yr, 11, 29 – Weekday(DateSerial(Yr, 11, 1), vbFriday))
End Function
Many date functions have been well described here.
Using the function we can now find out that Thanks-Giving falls on 11/25/2010 and 11/24/2011 in the years 2010 and 2011 respectively.

View the training video:

Further reading:

Leave a Reply

Your email address will not be published. Required fields are marked *