Date Entry
Thanks I'll give it a go
"Joel" wrote:
Try this code. I hard coded the year and day of week. Change as required.
the code puts the dates in column A
Sub MakeDates()
MyYear = 2009 'Change to Range("B1") or equivalent
DayofWeek = "Tuesday" 'Change to Range("C1") or equivalent.
DayCount = 0
Do
DayCount = DayCount + 1
DayName = WeekdayName(DayCount, False, vbSunday)
Loop While DayofWeek < DayName
FirstDay = DateValue("1/1/" & MyYear)
LastDay = DateValue("12/31/" & MyYear)
'Get First Day of year that matches DayofWeek
DayOffset = DayCount - Weekday(FirstDay)
If DayOffset < 0 Then DayOffset = DayOffset + 7
FirstDay = FirstDay + DayOffset
RowCount = 1
For DayCount = FirstDay To LastDay Step 7
Range("A" & RowCount) = Format(DayCount, "MMMM DD, YYYY")
RowCount = RowCount + 1
Next DayCount
End Sub
"Richard" wrote:
I have 2 drop down lists. 1 so that I can select the day ie Sunday the other
so that I can select a period ie Year 2009.
Would it be possible to have a macro create a list of all the dates which
match the criteria ie all Sundays in 2009.
Thanks in advance
Richard
|