Private Sub AllStaff_Click()
Dim LR
With Sheets("db").ListObjects(1).DataBodyRange
LR = .Parent.Evaluate("max(if(" & .Columns(1).Address & "<>"""",row(" & .Columns(1).Address & ")))") - .Row + 1
Me.ResultBox.List = Application.Index(.Value, Evaluate("row(1:" & LR & ")"), Array(2, 3, 4, 5, 6, 7, 9, 10, 11))
End With
With Me.ResultBox
.ColumnCount = 9
.ColumnWidths = "100;100;0;100;0;0;100;0;0"
End With
End Sub
Private Sub CurrentStaff_Click()
Dim x
Me.ResultBox.Clear
With Sheets("db").ListObjects(1).DataBodyRange
x = Filter(.Parent.Evaluate("transpose(if(" & .Columns(13).Address & "=""yes"",row(1:" & .Rows.Count & ")))"), False, 0)
If UBound(x) > -1 Then
If UBound(x) = 0 Then
Me.ResultBox.Column = Application.Index(.Value, Application.Transpose(x), Array(2, 3, 4, 5, 6, 7, 9, 10, 11))
Else
Me.ResultBox.List = Application.Index(.Value, Application.Transpose(x), Array(2, 3, 4, 5, 6, 7, 9, 10, 11))
End If
End If
End With
End Sub
Private Sub cmdLookup_Click()
Dim LR, a, i As Long, ii As Long, iii As Long
With Sheets("db").ListObjects(1).DataBodyRange
LR = .Parent.Evaluate("max(if(" & .Columns(1).Address & "<>"""",row(" & .Columns(1).Address & ")))") - .Row + 1
a = Application.Index(.Value, Evaluate("row(1:" & LR & ")"), Array(2, 3, 4, 5, 6, 7, 9, 10, 11))
End With
With Me.ResultBox
.Clear
For i = 1 To UBound(a, 1)
For ii = 1 To UBound(a, 2)
If UCase$(a(i, ii)) Like "*" & UCase$(Me.txtLookup) & "*" Then
.AddItem
For iii = 1 To UBound(a, 2)
.List(.ListCount - 1, iii - 1) = a(i, iii)
Next
Exit For
End If
Next
Next
End With
End Sub
Private Sub ResultBox_Click()
Dim i As Long, myCols
Me.ListBox2.Clear
myCols = Array(0, 1, 4, 5, 7, 8)
Me.ListBox2.ColumnCount = UBound(myCols) + 1
With Me.ResultBox
Me.ListBox2.AddItem
For i = 0 To UBound(myCols)
Me.ListBox2.List(0, i) = .List(.ListIndex, myCols(i))
Next
End With
End Sub
Bookmarks