1

Wondering if you could help with adding a value from my Worksheet to my TextBox1 depending on what ComboBox1 item is selected.

So far I have this for my ComboBox1 to pull a list from my Worksheet

Private Sub UserForm_Initialize()
' *** Load the companies into the delivering firm combo box ***
For Each cell In Range("RejectTitle")
    If cell <> "" Then
        Me.RejectTitleNm.AddItem cell
    End If
Next cell
End Sub

Now I am trying to have my UserForm show a value from Worksheet into TextBox1 depending on ComboBox but I believe I'm heading down the wrong path?

Private Sub RejectTitleNm_Change()
    Me.TextBox1.Text = Worksheets("Sheet1").Range("E5").Value
End Sub
0m3r
  • 12,286
  • 15
  • 35
  • 71
user3806255
  • 39
  • 1
  • 12

1 Answers1

0

Something like this:

Private Sub RejectTitleNm_Change()

    Dim f As Range, v

    v = Me.RejectTitleNm.Value
    'find the selected value in the source range
    Set f = Range("RejectTitle").Find(v, lookat:=xlWhole)

    Me.TextBox1.Text = ""
    If Not f Is Nothing Then
        'got a match: get value from ColB on same row
        Me.TextBox1.Text = f.EntireRow.Cells(, "B").Value
    End If

End Sub
Tim Williams
  • 154,628
  • 8
  • 97
  • 125