[FONT="]Hi,[/FONT]
[FONT="]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="]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="]example: selection from combo box
branch > Branch1
AGM > AGM1
RSM > RSM1
ALE > ALE1
BRAND > BRAND1[/FONT]
[FONT="]OUTPUT>>>>> [/FONT]
<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>
[FONT="]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="]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="]example: selection from combo box
branch > Branch1
AGM > AGM1
RSM > RSM1
ALE > ALE1
BRAND > BRAND1[/FONT]
[FONT="]OUTPUT>>>>> [/FONT]
Item | ITEM1 | ITEM2 | ITEM3 |
Total Qty | 2 | 1 | 1 |
Qty-% | 50% | 25% | 25% |
Stock Norm | 24 | 24 | 24 |
Closing Stock | 10 | 10 | 13 |
Stock Allocation | 12 | 6 | 6 |
Stock Status | -2 | 4 | 7 |
Excess/Less | Less | Excess | Excess |
<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>
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