how populate items in multiple comboboxes and textboxes without selection

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
241
Office Version
  1. 2019
  2. 2010
hi
I have many comboboxes(1,2,3,4) link with COL A,B,C,D and textboxes (1,2,3) link with COL E,F,G . so what I want when select combobox1 should filled the others comboboexs and textboxes based on data in sheet1 as in the pictures .
first when select item in combobox1
1.PNG


expected result fill the others comboboxes and textboxes
2.PNG
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Could you upload a sample workbook (without sensitive data) to a sharing site like dropbox.com or google drive?
And then share the link here.
This will make it easier to test & find a solution.
 
Upvote 0
Try this:
I assume col "BATCH" has unique values.
VBA Code:
Private Sub UserForm_Initialize()
With Sheets("Sheet1")
    With .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
        ComboBox1.List = .Value
        ComboBox2.List = .Offset(, 1).Value
        ComboBox3.List = .Offset(, 2).Value
        ComboBox4.List = .Offset(, 3).Value
    End With
End With

End Sub

Private Sub ComboBox1_Change()
Dim c As Range
With Sheets("Sheet1")
   
    Set c = .Range("A:A").Find(What:=ComboBox1.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    If Not c Is Nothing Then
        ComboBox2.Value = c.Offset(, 1).Value
        ComboBox3.Value = c.Offset(, 2).Value
        ComboBox4.Value = c.Offset(, 3).Value
        TextBox1.Value = c.Offset(, 4).Value
        TextBoxPrice.Value = c.Offset(, 5).Value
        TextBoxTotal.Value = c.Offset(, 6).Value
    End If
End With
End Sub
 
Upvote 0
Solution
magificiant ! you've answered my question . curiosity if I add multiple comboboxes and textboxes withe same structure. I see your code and I can add it but the code becomes more long . if there is way to make short will be greate . like this

VBA Code:
With .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
        ComboBox1.List = .Value
        ComboBox2.List = .Offset(, 1).Value
        ComboBox3.List = .Offset(, 2).Value
        ComboBox4.List = .Offset(, 3).Value
        ComboBox5.List = .Value
        ComboBox6.List = .Offset(, 1).Value
        ComboBox7.List = .Offset(, 2).Value
        ComboBox8.List = .Offset(, 3).Value
        ComboBox9.List = .Value
        ComboBox10.List = .Offset(, 1).Value
        ComboBox11.List = .Offset(, 2).Value
        ComboBox12.List = .Offset(, 3).Value
    End With
and
Code:
If Not c Is Nothing Then
        ComboBox2.Value = c.Offset(, 1).Value
        ComboBox3.Value = c.Offset(, 2).Value
        ComboBox4.Value = c.Offset(, 3).Value
        TextBox1.Value = c.Offset(, 4).Value
        TextBoxPrice.Value = c.Offset(, 5).Value
        TextBoxTotal.Value = c.Offset(, 6).Value
        
        ComboBox6.Value = c.Offset(, 1).Value
        ComboBox7.Value = c.Offset(, 2).Value
        ComboBox8.Value = c.Offset(, 3).Value
        TextBox4.Value = c.Offset(, 4).Value
        TextBoxPrice1.Value = c.Offset(, 5).Value
        TextBoxTotal1.Value = c.Offset(, 6).Value
        ComboBox10.Value = c.Offset(, 1).Value
        ComboBox11.Value = c.Offset(, 2).Value
        ComboBox12.Value = c.Offset(, 3).Value
        TextBox7.Value = c.Offset(, 4).Value
        TextBoxPrice2.Value = c.Offset(, 5).Value
        TextBoxTotal2.Value = c.Offset(, 6).Value
        
    End If
if this is not clear I will attach pic
 
Upvote 0
For the first example, try:
VBA Code:
With .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
        For i = 1 To 4
            Me.Controls("ComboBox" & i) = .Offset(, i - 1).Value
            Me.Controls("ComboBox" & i + 4) = .Offset(, i - 1).Value
            Me.Controls("ComboBox" & i + 8) = .Offset(, i - 1).Value
        Next
End With
 
Upvote 0
Sorry, try this one:
VBA Code:
Private Sub UserForm_Initialize()
With Sheets("Sheet1")
    With .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
        For i = 1 To 4
            Me.Controls("ComboBox" & i).List = .Offset(, i - 1).Value
            Me.Controls("ComboBox" & i + 4).List = .Offset(, i - 1).Value
            Me.Controls("ComboBox" & i + 8).List = .Offset(, i - 1).Value
        Next
    End With
End With

End Sub

but you need to place the comboboxes in correct order.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,551
Members
449,170
Latest member
Gkiller

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