Hi Jerry
just a quick comment, if your using VBA anyway you can do this slightly neater
to use a worksheet function for the date you can use
=DATE(YEAR($S1),MONTH($S1),1) and then format this to month year
or you can use DateSerial and store this to a variable you can also subtract 1 from the day and it will produce the end date as you have above with cells
Here's an example of what i think your trying to do
Code:
Private Sub UserForm_Activate()
Dim wksData As Worksheet
Dim fdom() As Date
Dim Lastrow As Long
'set object variable
Set wksData = Worksheets("Sheet1")
Lastrow = wksData.Cells(Rows.Count, 1).End(xlUp).Row
'reset array sizes to hold the data
ReDim fdom(Lastrow) As Date
ReDim ldom(Lastrow) As Date
'fill the array with intial dates of the months in the first cell
For i = 1 To Lastrow
fdom(i) = DateSerial(Year(wksData.Cells(i, 1).Value), Month(wksData.Cells(i, 1).Value), 1)
Next i
'put array on worksheet
For i = 1 To Lastrow
wksData.Cells(i, 3).Value = Format(fdom(i), "mmm YYYY")
Next i
'put the dates onto the worksheet then filter them
With Range(wksData.Cells(1, 3), wksData.Cells(Lastrow, 3))
.Sort Cells(1, 3), xlAscending
.AdvancedFilter xlFilterCopy, , Cells(1, 6), True
End With
'get the new number of rows to fill array with
Lastrow = wksData.Cells(Rows.Count, 6).End(xlUp).Row
'resize array to new size this also clears the array
ReDim fdom(Lastrow) As Date
For i = 1 To Lastrow
'Fill when list is filtered if statement to remove inital value if applicable
If Not (i = 1 And wksData.Cells(1, 6).Value = wksData.Cells(2, 6).Value) Then
ListBox1.AddItem Format(wksData.Cells(i, 6).Value, "mmm yyyy")
End If
Next i
'clear working of of worksheet
wksData.Cells(1, 3).EntireColumn.Clear
wksData.Cells(1, 6).EntireColumn.Clear
End Sub
HTH
Dave