I have the following code to populate a ComboBox in User form with a unique list of dates, where the CDate function does not seem to work. I have also used the CLng function but that does not seem to work either. The routine works fine if I have a list of Names using the CStr function.
Can someone offer me a solution please
Private Sub UserForm_Initialize()
Dim Found As Long, i As Long
Dim cel As Range
'Create date List
MyList = "valEndDate" ' This is a list of Dates
Set DataList = Range(MyList)
ReDim FArray(DataList.Cells.Count)
i = -1
For Each cel In DataList
On Error Resume Next
Found = Application.WorksheetFunction.Match(CDate(cel), FArray, 0)
If Found > 0 Then GoTo Exists
i = i + 1
FArray(i) = cel
Exists:
Found = 0
Next
ReDim Preserve FArray(i)
Call BubbleSort(FArray)
ComboBox1.ListRows = i + 1
ComboBox1.List() = FArray
End Sub
Many thanks for assistance/sglxl
Bookmarks