View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_280_] Leith Ross[_280_] is offline
external usenet poster
 
Posts: 1
Default Date Format Question


Hello Minitman,

I am not sure what Tom would do, but this is my approach. Find th
first Sunday back from the 1st of next month. This assumes Sunday i
the First day of the week.

Add a VBA Module to your project and copy this code to it. This macr
can be used as a Worksheet Formula or as a VBA Function call. Be sur
to format the Cell or Variable as a Date.

WORKSHEET FORMULA EXAMPLE
=LastSunday()


Code
-------------------
Public Function LastSunday() As Date

Dim D, X

X = DateSerial(Year(Now), Month(Now)+1, 1)
D = Weekday(X) - 1

LastSunday = X - D

End Function

-------------------

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48476