Hello
my data as in picture
I want merging QTY into textbox1 based on column C,D after matching combobox1,2 with columns C,D like this
current code will merge based on combobox1 is matched with column D
I hope somebody can adapt with my requirements.
my data as in picture
BR.xlsm | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | ITEM | DATE | CUSTOMER | ID | QTY | ||
2 | 1 | 01/01/2024 | mkl1 | SDFR1000 | 200 | ||
3 | 2 | 01/01/2024 | mkl1 | SDFR1000 | 300 | ||
4 | 3 | 01/01/2024 | mkl1 | SDFR1000 | 100 | ||
5 | 4 | 01/01/2024 | mkl1 | SDFR1001 | 200 | ||
6 | TOTAL | 01/01/2024 | 110 | ||||
7 | 1 | 02/01/2024 | malk | SDFR1000 | 200 | ||
8 | 2 | 02/01/2024 | malk | SDFR1002 | 300 | ||
9 | TOTAL | 02/01/2024 | 110 | ||||
ORDERS |
I want merging QTY into textbox1 based on column C,D after matching combobox1,2 with columns C,D like this
current code will merge based on combobox1 is matched with column D
VBA Code:
Private Sub CommandButton1_Click()
Dim ws As Worksheet, LR As Long, qtyP As Double, qtyT As Double
If ComboBox1.Value <> "" Then
Set ws = Sheets("ORDERS")
LR = ws.Cells(Rows.Count, 3).End(3).Row
qtyP = WorksheetFunction.SumIf(ws.Range("D2:D" & LR), ComboBox1.Value, ws.Range("E2:E" & LR))
qtyT = qtyT + qtyP
TextBox1.Text = qtyT
End If
End Sub