Private Sub GetLastSaturday()
Dim DayNum As Integer, _
startDate As Date, _
lastDate As Date, _
firstWeekEnd As Date
'Pass a value from your spreadsheet to here
'I hard-coded this for testing / illustrative purposes only
startDate = DateSerial(2006, 10, 1)
'Find the last day of the month
lastDate = DateAdd("d", -1, DateSerial(Year(DateAdd("m", 1, startDate)), _
Month(DateAdd("m", 1, startDate)), 1))
'Get the day number where 1 = Sunday
DayNum = Weekday(lastDate, vbSunday)
If DayNum < 7 Then
'Last day is not a Saturday
'so subtract the weekday number to find the last Saturday
firstWeekEnd = DateAdd("d", -Weekday(lastDate, vbSunday), lastDate)
Else
'last day is a Saturday
firstWeekEnd = lastDate
End If
'Included for testing purpose only
'Instead you should either return the value to a cell (or the function)
MsgBox "The last Saturday for " & Month(startDate) & "/" & Year(startDate) _
& " is " & Format(firstWeekEnd, "mm/dd/yyyy")
End Sub