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]
ItemITEM1ITEM2ITEM3
Total Qty211
Qty-%50%25%25%
Stock Norm242424
Closing Stock101013
Stock Allocation1266
Stock Status-247
Excess/LessLessExcessExcess


<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;">
</tbody>


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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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