fixing code populate data in multiple textboxes based on multiple comboboxes

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
985
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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,682
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,682
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,861
Messages
5,627,315
Members
416,239
Latest member
Counselor85027

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