View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Please help Please help is offline
external usenet poster
 
Posts: 75
Default Creating Lookup User Form

merjet,

Sorry about the long message previously posted.

I have figured out why I got an error. I got an error because I inserted a
cell reference in the ControlSource of combo box. When I removed it, I was
no longer receiving errors. However, I am no longer able to list my values
"student numbers" in the combo box, even though I have "B:B" in the
RowSource.

Do you know how I can list student numbers in the combo box? The student
numbers are in column B.

Thanks.

"merjet" wrote:

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