Digitborn.com
Active Member
- Joined
- Apr 3, 2007
- Messages
- 353
Hello,
I have a code which works perfectly and adds the dates from Column A to UserForm1 ComboBox2.
In column B, I have textdata - UserForm1 ComboBox5.
I'd like to transform the code to add only the dates which correspond (cascading) to 1.1 textdata in ComboBox5 (Column B) and 1.2 dates in ComboBox2 (Column A).
Normaly I know how to do it -> ComboBox2.AddItem = r.Offset(, 1).Value but in this case Me.ComboBox2.List = dic.keys is unknown for me. All code for ComboBox2 is written because of the dates format and sort.
I have a code which works perfectly and adds the dates from Column A to UserForm1 ComboBox2.
In column B, I have textdata - UserForm1 ComboBox5.
I'd like to transform the code to add only the dates which correspond (cascading) to 1.1 textdata in ComboBox5 (Column B) and 1.2 dates in ComboBox2 (Column A).
Code:
ElseIf ComboBox5.ListIndex <> 0 Then
ComboBox2.Style = fmStyleDropDownList
ComboBox2.Enabled = True
ComboBox2.SetFocus
For Each r In Worksheets("PartsData").Range("A2:A59")
If r.Offset(, 1).Value = Trim(ComboBox5.Value) Then
Dim dic As Object, e, d, a
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = vbTextCompare
With Sheets("PartsData")
With .Range("A2:AD" & .Range("A" & Rows.Count).End(xlUp).Row)
.Sort .Range("A2"), xlAscending
a = .Offset(0, 0).Resize(, 1).Value
End With
End With
For Each e In a
If Not IsEmpty(e) Then
d = Format(e, "dd-mmm-yy")
If Not dic.exists(d) Then dic.Add d, Nothing
End If
Next
Me.ComboBox2.List = dic.keys
Set dic = Nothing: Erase a
End If
Next
End If