VBA : Create loop to update Multiple Textboxes based on ComboBox Selection

KMGIL

New Member
Joined
Dec 16, 2014
Messages
26
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





Email AddressOperating UnitPO NumberPO LinePO PreparerVendorDeliver to PersonCREATION_DATECurrency Accounted AmountComment
km@abc.comES-OU-0112341kenAbcken06-Sep-18EUR39.34 Q1.19 RNV - Low values
sb@abc.comFR-OU-0112352SimonDefSimon29-Aug-14EUR42.00 Q1.19 RNV - Low values
Jmc@abc.comFR-OU-0132654JoGHIJo19-Oct-18EUR0.62 Q1.19 RNV - Low values
km@abc.comES-OU-0145781kenAbcken06-Sep-18EUR39.34 Q1.19 RNV - Low values
sb@abc.comFR-OU-0112452SimonDef1Simon29-Aug-14EUR25.00 Q1.19 RNV - Low values
Jmc@abc.comFR-OU-0125474JoGHIJo19-Oct-18EUR15.64 Q1.19 RNV - Low values
km@abc.comES-OU-01875461kenAbcken06-Sep-18EUR1,478.00 Q1.19 RNV - Low values
sb@abc.comFR-OU-01222232SimonDefSimon29-Aug-14EUR25.00 Q1.19 RNV - Low values
Jmc@abc.comFR-OU-0122484JoGHI2Jo19-Oct-18EUR15.00 Q1.19 RNV - Low values
km@abc.comES-OU-0122581kenAbcken06-Sep-18EUR37.50 Q1.19 RNV - Low values
sb@abc.comFR-OU-01956872SimonDefSimon29-Aug-14EUR22.00 Q1.19 RNV - Low values
Jmc@abc.comFR-OU-0112454JoGHIJo19-Oct-18EUR13.48 Q1.19 RNV - Low values
km@abc.comES-OU-01111111kenAbc3ken06-Sep-18EUR7.25 Q1.19 RNV - Low values
sb@abc.comFR-OU-0133332SimonDefSimon29-Aug-14EUR6.00 Q1.19 RNV - Low values
Jmc@abc.comFR-OU-01665874JoGHIJo19-Oct-18EUR19.68 Q1.19 RNV - Low values
<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>
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,215,829
Messages
6,127,127
Members
449,361
Latest member
VBquery757

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top