Creating Lookup User Form
Suppose the data is in columns A-C of Sheet1, with #
in column B. Set the ComboBox's RowSource property
like this: Sheet1!B2:B6
Put the following code in the UserForm's code module:
Private Sub ComboBox1_Change()
Dim rng As Range
With ComboBox1
If .ListIndex = -1 Then
TextBox1 = ""
TextBox2 = ""
Else
Set rng = Range(.RowSource)(.ListIndex + 1)
TextBox1 = rng.Offset(0, -1)
TextBox2 = rng.Offset(0, 1)
End If
End With
End Sub
Hth,
Merjet
|