fixing code populate data in multiple textboxes based on multiple comboboxes

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
977
Office Version
  1. 2010
hello

I need help about find way to populate data in textbox based on select from combo box it works only combobox1 & textbox1
what I want the rests of combobox when I select item then populate in textbox



VBA Code:
Private Sub ComboBox1_Change()
 Me.TextBox1.Value = Sheets("Sheet1").Range("e" & Me.ComboBox1.ListIndex + 2).Value
 Me.TextBox2.Value = Sheets("Sheet1").Range("e" & Me.ComboBox2.ListIndex + 2).Value
 Me.TextBox3.Value = Sheets("Sheet1").Range("e" & Me.ComboBox3.ListIndex + 2).Value
 Me.TextBox4.Value = Sheets("Sheet1").Range("e" & Me.ComboBox4.ListIndex + 2).Value
End Sub


Private Sub UserForm_Initialize()
With Sheets("Sheet1")
      Me.ComboBox1.List = .Range("b2:b" & .Range("A" & Rows.Count).End(xlUp).Row).Value
       Me.ComboBox2.List = .Range("b2:b" & .Range("A" & Rows.Count).End(xlUp).Row).Value
       Me.ComboBox3.List = .Range("b2:b" & .Range("A" & Rows.Count).End(xlUp).Row).Value
      Me.ComboBox4.List = .Range("b2:b" & .Range("A" & Rows.Count).End(xlUp).Row).Value
   End With
End Sub
thanks
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,231
Office Version
  1. 365
Platform
  1. Windows
Either put your Combo change event code into a command button, or just populate each textbox from the relevant combo change event.
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,231
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,957
Messages
5,621,823
Members
415,859
Latest member
Vain

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
Top