Multiple Dependency combo box Excel 2010 VBA.

Gskr3499

New Member
Joined
Sep 22, 2018
Messages
1
[FONT=&quot]Hi,[/FONT]
[FONT=&quot]I am trying to populate values from the database sheet. I have already build combo box using vba. attached vba code below for reference.[/FONT]
[FONT=&quot]The problem is am getting only the first cell values of column item1. i need to get all the items selection branch,AGM,RSM,ALE,BRAND[/FONT]
[FONT=&quot]example: selection from combo box
branch > Branch1
AGM > AGM1
RSM > RSM1
ALE > ALE1
BRAND > BRAND1[/FONT]

[FONT=&quot]OUTPUT>>>>> [/FONT]
[TABLE="width: 245"]
<colgroup><col width="107" style="width: 80pt;"><col width="44" style="width: 33pt;"><col span="2" width="47" style="width: 35pt;"></colgroup><tbody style="border: 0px; font-weight: inherit; font-style: inherit; font-family: inherit; margin: 0px; outline: 0px; padding: 0px;">[TR]
[TD="width: 107"]Item[/TD]
[TD="width: 44"]ITEM1[/TD]
[TD="width: 47"]ITEM2[/TD]
[TD="width: 47"]ITEM3[/TD]
[/TR]
[TR]
[TD]Total Qty[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Qty-%[/TD]
[TD="align: right"]50%[/TD]
[TD="align: right"]25%[/TD]
[TD="align: right"]25%[/TD]
[/TR]
[TR]
[TD]Stock Norm[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"]24[/TD]
[/TR]
[TR]
[TD]Closing Stock[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD]Stock Allocation[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD]Stock Status[/TD]
[TD="align: right"]-2[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]Excess/Less[/TD]
[TD]Less[/TD]
[TD]Excess[/TD]
[TD]Excess

[/TD]
[/TR]
</tbody>[/TABLE]


1339428

1339431


HTML:
Private Sub choice1_Change()    Range("F8:F15").ClearContents
    Choice2.ListIndex = -1
    Choice3.ListIndex = -1
    Choice4.ListIndex = -1
    Choice5.ListIndex = -1
    If choice1.ListIndex > -1 Then Choice2.List = Split(f_list(1), ",")
End Sub
Private Sub choice2_Change()
    If Choice2.ListIndex > -1 Then Choice3.List = Split(f_list(2), ",")
End Sub
Private Sub choice3_Change()
    If Choice3.ListIndex > -1 Then Choice4.List = Split(f_list(3), ",")
End Sub
Private Sub choice4_Change()
    If Choice4.ListIndex > -1 Then Choice5.List = Split(f_list(4), ",")
End Sub
Function f_list(x)
    sn = Sheets("database").Cells(1).CurrentRegion
    For j = 1 To UBound(sn)
        For jj = 1 To x
               If sn(j, jj) <> Sheets("Stock").OLEObjects("choice" & jj).Object.Value Then Exit For
        Next
        If jj = x + 1 And InStr(c01 & ",", "," & sn(j, jj) & ",") = 0 Then c01 = c01 & "," & sn(j, jj)
    Next
    f_list = Mid(c01, 2)
End Function


Private Sub choice5_Change()
    If Choice5.ListIndex = -1 Then Exit Sub
    
    sn = Sheets("database").Cells(1).CurrentRegion
    c01 = choice1.Value & Choice2.Value & Choice3.Value & Choice4.Value & Choice5.Value

    For j = 1 To UBound(sn)
        If sn(j, 1) & sn(j, 2) & sn(j, 3) & sn(j, 4) & sn(j, 5) = c01 Then
            Range("F8:F15") = Application.Transpose(Array(sn(j, 6), sn(j, 7), sn(j, 8), sn(j, 9), sn(j, 10), sn(j, 11), sn(j, 12), sn(j, 13)))
            Exit For
        End If
    Next 
End Sub

HTML:
Private Sub Workbook_Open()    sn = Sheets("database").Cells(1).CurrentRegion
    For j = 1 To UBound(sn)
        If InStr(c01 & ",", "," & sn(j, 1) & ",") = 0 Then c01 = c01 & "," & sn(j, 1)
    Next
    
    With Sheets("Stock")
        .choice1.List = Split(Mid(c01, 2), ",")
        .Choice2.Clear
        .Choice3.Clear
        .Choice4.Clear
        .Choice5.Clear
        .Range("F8:F15").ClearContents
    End With
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

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