Returning Values
Eric,
For Part 1:
Private Sub ComboBox1_Change()
Set ws1 = Worksheets("Sheet1") '<=== change as required
ws1.Activate
With ws1
res = Application.Match(ComboBox1.Value, Range("A:A"), 0)
If IsError(res) Then
MsgBox ComboBox1.Value & " not found"
Else
For i = 1 To 3 ' populate textboxes 1 to 3
Me.Controls("textbox" & i) = .Cells(res, i + 1)
Next i
End If
End With
End Sub
For Part 2: do you have a command button to "submit" the text box updates?
If so, then code should go in the Commandbutton_Click macro.
Something like:
private sub commandbutton1_click
Set ws1 = Worksheets("Sheet1") '<=== change as required
ws1.Activate
With ws1
res = Application.Match(ComboBox1.Value, Range("A:A"), 0)
If IsError(res) Then
MsgBox ComboBox1.Value & " not found"
Else
For i = 1 To 3 ' populate cells with textboxes 1 to 3
If Me.Controls("textbox" & i) < "" then .Cells(res, i +
1)=Me.Controls("textbox" & i).value
Next i
End If
End With
End sub
HTH
"Eric" wrote:
Hello there, I have a UserForm on which there is 1 ComboBox (ComboBox1) and 3
TextBoxes (Textboxes 1,2,3). The values for ComboBox1 and the TextBoxes are
stored in multiple columns on a sheet within the workbook. (Sheet1) (Columns
A,B,C,D) What I would like to do is this: When a user selects a value from
ComboBox1 (Gathered from Column A), I would like the Textboxes to
automatically fill in based upon the values from Columns B,C, and D
respectively. That is part one.
Part two, If the information gathered needs to be changed, I would like the
user to be able to change it in the Textbox and have the values automatically
update on the sheet. Any help would really be appreciated.
|