PDA

View Full Version : Select dates by current month



peterwmartin
07-31-2012, 01:27 AM
Hi all,
I have a workbook with a work roster calendar, I need to select the dates on the calander sheet which are within the current month.
the calendar looks like this

week 1 Week 2
wed thurs mon tue fri sat sun
I have created the calendar though need to select and paste dates for current month to another sheet
Better still does anyone know how to program that roster? although there is a patern I can't seem to create it.
Any hint's here would be appreciated

Bob Phillips
07-31-2012, 02:20 AM
Can you post an example workbook?

peterwmartin
07-31-2012, 03:11 AM
Hi Here is the worksheets copied to a new workbook
it has 3 versions of the calendar

serj1980
08-01-2012, 03:34 AM
maybe this help you
Dim cSelectedDates As New Collection
For i = 1 To 50
For j = 1 To 20
If IsDate(ActiveSheet.Cells(i, j).Value) Then
If (DatePart("m", ActiveSheet.Cells(i, j).Value) = DatePart("m", Date) _
And DatePart("yyyy", ActiveSheet.Cells(i, j).Value) = DatePart("yyyy", Date)) Then
cSelectedDates.Add ActiveSheet.Cells(i, j).Value
End If
End If
Next j
Next i
' at this place you have all selected dates in cSelectedDates variable