Texbox values based on Combobox Value(more detail)
Hey Tom,
I finally got it to work. Thank you for your help. I had
to remove the Option Explicit part. That was the reason I
was receiving the error. Below is what I removed from the
top of the entire module:
*******
Option Explicit
Dim cLastRow As Long
Dim i As Long
********
Instead of using the Option Explicit, I just copied the 2
lines of code to each of the 3 OptionButton code (which it
pertains to). Do you know why when I removed the Option
Explicit, it worked?
Below is the code you wrtoe that I am using.
"Here is the second piece of code, copied out of a working
module:"
Private Sub Combobox1_Click()
If ComboBox1.ListIndex < -1 Then
With Worksheets("sheet2")
If OptionButton1.Value Then
Set rng = .Range("A2:A52")
ElseIf OptionButton2.Value Then
Set rng = .Range("B2:B52")
Else
Set rng = .Range("C2:C52")
End If
For Each cell In rng
If cell.Text = ComboBox1.Value Then
TextBox1.Value = .Cells(cell.Row, 1).Value
TextBox2.Value = .Cells(cell.Row, 2).Value
TextBox3.Value = .Cells(cell.Row, 3).Value
Exit For
End If
Next
End With
End If
End Sub
Thanx again,
Todd
|