Userform ListBox multiple columns issue

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
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,215,013
Messages
6,122,694
Members
449,092
Latest member
snoom82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top