03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I have a userform that includes a combobox (CBO_EMPLOYEE), a listbox (LST_RECORDS), and a search button (CMD_SEARCH). When the user chooses the employee from the combobox and hits the search button, the listbox list the correct number of employee records including the name from column 3, and the supervisor from column 1. I also need to include the Date (column 11) from the dataTable but am unable to do so. Can someone help me tweak my code to include the Date column.
VBA Code:
Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
Set WS = Worksheets("Absentee")
Dim v, e
With Sheets("Absentee").Range("Table1[Employee]")
v = .value
End With
With CreateObject("scripting.dictionary")
.comparemode = 1
For Each e In v
If Not .exists(e) Then .Add e, Nothing
Next
If .Count Then Me.CBO_EMPLOYEE.List = Application.Transpose(.keys)
End With
Application.ScreenUpdating = True
End Sub
'====================================================================================================
Private Sub CMD_SEARCH_Click()
LST_RECORDS.Clear
Dim RowNum As Long
RowNum = 1
Do Until Sheets("Absentee").Cells(RowNum, 3).value = ""
If InStr(1, Sheets("Absentee").Cells(RowNum, 3).value, CBO_EMPLOYEE.value, vbTextCompare) > 0 Then
On erro GoTo next1
LST_RECORDS.AddItem Sheets("Absentee").Cells(RowNum, 1).value
LST_RECORDS.List(LST_RECORDS.ListCount - 1, 1) = Sheets("Absentee").Cells(RowNum, 3).value
End If
next1:
RowNum = RowNum + 1
Loop
End Sub