Hi
I am trying to update multiple textbox based on selection in a combo box
The Combox section is based on an email address . This email address could appear multiple times in the data base and I need to return data in the Textboxes for each line.
I have created a form and am able to update the first row of textboxes but am not sure how I can loop I to update the second row. Also when I click on the drop down option of the ComboBox I get to see the multiple times the email name I there
Please see below my initial code and expel of what database looks like
Appreciate any help
Many Thanks
Kind Regards
Ken
Private Sub ComboBox1_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet1")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If (Me.ComboBox1.Value) = ws.Cells(i, "A") Then
Me.TextBox1 = ws.Cells(i, "C").Value
Me.TextBox2 = ws.Cells(i, "D").Value
Me.TextBox3 = ws.Cells(i, "F").Value
Me.TextBox4 = ws.Cells(i, "J").Value
End If
Next i
End Sub
Private Sub UserForm_Initialize()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet1")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
Me.ComboBox1.AddItem ws.Cells(i, "A").Value
Next i
End Sub
<colgroup><col width="170" style="width: 128pt; mso-width-source: userset; mso-width-alt: 6217;">
<col width="100" style="width: 75pt; mso-width-source: userset; mso-width-alt: 3657;">
<col width="79" style="width: 59pt; mso-width-source: userset; mso-width-alt: 2889;">
<col width="54" style="width: 41pt; mso-width-source: userset; mso-width-alt: 1974;">
<col width="148" style="width: 111pt; mso-width-source: userset; mso-width-alt: 5412;">
<col width="53" style="width: 40pt; mso-width-source: userset; mso-width-alt: 1938;">
<col width="201" style="width: 151pt; mso-width-source: userset; mso-width-alt: 7350;">
<col width="110" style="width: 83pt; mso-width-source: userset; mso-width-alt: 4022;">
<col width="62" style="width: 47pt; mso-width-source: userset; mso-width-alt: 2267;">
<col width="131" style="width: 98pt; mso-width-source: userset; mso-width-alt: 4790;">
<col width="154" style="width: 116pt; mso-width-source: userset; mso-width-alt: 5632;">
<tbody>
</tbody>
I am trying to update multiple textbox based on selection in a combo box
The Combox section is based on an email address . This email address could appear multiple times in the data base and I need to return data in the Textboxes for each line.
I have created a form and am able to update the first row of textboxes but am not sure how I can loop I to update the second row. Also when I click on the drop down option of the ComboBox I get to see the multiple times the email name I there
Please see below my initial code and expel of what database looks like
Appreciate any help
Many Thanks
Kind Regards
Ken
Private Sub ComboBox1_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet1")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If (Me.ComboBox1.Value) = ws.Cells(i, "A") Then
Me.TextBox1 = ws.Cells(i, "C").Value
Me.TextBox2 = ws.Cells(i, "D").Value
Me.TextBox3 = ws.Cells(i, "F").Value
Me.TextBox4 = ws.Cells(i, "J").Value
End If
Next i
End Sub
Private Sub UserForm_Initialize()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet1")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
Me.ComboBox1.AddItem ws.Cells(i, "A").Value
Next i
End Sub
Email Address | Operating Unit | PO Number | PO Line | PO Preparer | Vendor | Deliver to Person | CREATION_DATE | Currency | Accounted Amount | Comment |
km@abc.com | ES-OU-01 | 1234 | 1 | ken | Abc | ken | 06-Sep-18 | EUR | 39.34 | Q1.19 RNV - Low values |
sb@abc.com | FR-OU-01 | 1235 | 2 | Simon | Def | Simon | 29-Aug-14 | EUR | 42.00 | Q1.19 RNV - Low values |
Jmc@abc.com | FR-OU-01 | 3265 | 4 | Jo | GHI | Jo | 19-Oct-18 | EUR | 0.62 | Q1.19 RNV - Low values |
km@abc.com | ES-OU-01 | 4578 | 1 | ken | Abc | ken | 06-Sep-18 | EUR | 39.34 | Q1.19 RNV - Low values |
sb@abc.com | FR-OU-01 | 1245 | 2 | Simon | Def1 | Simon | 29-Aug-14 | EUR | 25.00 | Q1.19 RNV - Low values |
Jmc@abc.com | FR-OU-01 | 2547 | 4 | Jo | GHI | Jo | 19-Oct-18 | EUR | 15.64 | Q1.19 RNV - Low values |
km@abc.com | ES-OU-01 | 87546 | 1 | ken | Abc | ken | 06-Sep-18 | EUR | 1,478.00 | Q1.19 RNV - Low values |
sb@abc.com | FR-OU-01 | 22223 | 2 | Simon | Def | Simon | 29-Aug-14 | EUR | 25.00 | Q1.19 RNV - Low values |
Jmc@abc.com | FR-OU-01 | 2248 | 4 | Jo | GHI2 | Jo | 19-Oct-18 | EUR | 15.00 | Q1.19 RNV - Low values |
km@abc.com | ES-OU-01 | 2258 | 1 | ken | Abc | ken | 06-Sep-18 | EUR | 37.50 | Q1.19 RNV - Low values |
sb@abc.com | FR-OU-01 | 95687 | 2 | Simon | Def | Simon | 29-Aug-14 | EUR | 22.00 | Q1.19 RNV - Low values |
Jmc@abc.com | FR-OU-01 | 1245 | 4 | Jo | GHI | Jo | 19-Oct-18 | EUR | 13.48 | Q1.19 RNV - Low values |
km@abc.com | ES-OU-01 | 11111 | 1 | ken | Abc3 | ken | 06-Sep-18 | EUR | 7.25 | Q1.19 RNV - Low values |
sb@abc.com | FR-OU-01 | 3333 | 2 | Simon | Def | Simon | 29-Aug-14 | EUR | 6.00 | Q1.19 RNV - Low values |
Jmc@abc.com | FR-OU-01 | 66587 | 4 | Jo | GHI | Jo | 19-Oct-18 | EUR | 19.68 | Q1.19 RNV - Low values |