Place this code In a standard module:
Option Explicit
Sub ListBoxForm()
UserForm1.Show
End Sub
Place this code In the module For your userform:
Option Explicit
Private Sub UserForm_activate()
Dim MyList(10, 3)
Dim R As Integer
Application.ShowToolTips = True
With ListBox1
.ColumnCount = 3
.ColumnWidths = 75
.Width = 230
.Height = 110
.ControlTipText = "Click the Name, Job, or ID you're after"
End With
With ActiveSheet
For R = 0 To 9
MyList(R, 0) = .Range("A" & R + 1)
MyList(R, 1) = .Range("D" & R + 1)
MyList(R, 2) = .Range("G" & R + 1)
Next R
End With
ListBox1.List = MyList
End Sub
Private Sub listBox1_Click()
Dim Employee As Variant
Dim Name As String
Dim firstaddress As String
Employee = Empty
With ActiveSheet.Range("a1:a500")
Name = ListBox1.Value
Set Employee = .Find(what:=Name, LookIn:=xlValues)
If Not Employee Is Nothing Then Employee.Rows.EntireRow.Select Else Exit Sub
End With
Unload Me
Set Employee = Nothing
End Sub
|