match based on three comboboxes for multiple separated range from userform

Maklil

Board Regular
Joined
Jun 23, 2022
Messages
174
Office Version
  1. 2019
Platform
  1. Windows
Hi experts ,
I need matchin combobox1,2,3 with columns B:D for sheet . I want when fill data on userform combobox1,2,3 ,textbox1, then will copy to separated range is matched with combobox1,2,3 , as to textbox2 just I want showing remaining values , it depends on subtraction the value in first row from others values under first row , for instance if I write 50 in textbox1 , then textbox2 will populate value from sheet is 100- 50 which fill in textbox2 then will show 50 in textbox2 as in pic2 , if I write 20 in textbox1 then textbox2 will populate value from sheet is 100- (50+20) which fill in textbox2 then will show 30 in textbox2 as in pic4 so when show the values in textbox2 depends on first row contains value in column E subtract from aggregate under firs row .
when copy data to sheet should show the date today in column A .

MAKLIL.xlsm
ABCDE
1DATECUSTOMERINV NOITEMQTY
211/11/2022CSS-100INV-A123ITTT-100/AS-1100
3
4DATECUSTOMERINV NOITEMQTY
511/11/2022CSS-100INV-A123ITTT-100/AS-2200
6
7DATECUSTOMERINV NOITEMQTY
811/11/2022CSS-102INV-A125ITTT-100/AS-2300
9
10DATECUSTOMERINV NOITEMQTY
1111/11/2022CSS-103INV-A126ITTT-100/AS-2100
12
13DATECUSTOMERINV NOITEMQTY
1411/11/2022CSS-100INV-A124ITTT-100/AS-2200
15
16DATECUSTOMERINV NOITEMQTY
1711/11/2022CSS-105INV-A128ITTT-100/AS-6400
18
19DATECUSTOMERINV NOITEMQTY
2011/11/2022CSS-100INV-A129ITTT-100/AS-7300
DETAILS




fill the userform
2.JPG


copy to sheet for separated range
MAKLIL.xlsm
ABCDE
1DATECUSTOMERINV NOITEMQTY
211/11/2022CSS-100INV-A123ITTT-100/AS-1100
317/12/2022CSS-100INV-A123ITTT-100/AS-150
DETAILS


another process

fill userform

3.JPG




copy to sheet
MAKLIL.xlsm
ABCDE
1DATECUSTOMERINV NOITEMQTY
211/11/2022CSS-100INV-A123ITTT-100/AS-1100
317/12/2022CSS-100INV-A123ITTT-100/AS-150
417/12/2022CSS-100INV-A123ITTT-100/AS-120
DETAILS
 
I no know if you understand me . your code just adds the values for textbox2 and ignores comboboxes .

what I want when add new row should be with the same borders as in previous row
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Thats all I can understand. Sorry.
VBA Code:
Sub addItem()
  Dim lRow As Long
  Dim lValue As Variant

  lRow = Worksheets("DETAILS").Cells(Rows.Count, 1).End(xlUp).Row
  With Worksheets("DETAILS")
    For i = lRow To 2 Step-1
      If .Cells(i, 2).Value = UserForm1.ComboBox1.Value And .Cells(i, 3).Value = UserForm1.ComboBox2.Value And .Cells(i, 4).Value = UserForm1.ComboBox3.Value Then
        lValue = .Cells(i, 5).Value - UserForm1.TextBox1.Value
        UserForm1.TextBox2.Value = lValue
        .Rows(i).Copy
        .Rows(i + 1). EntireRow.Insert
        .Cells(i + 1, 5).Value = lValue
        Exit For
      End If
    Next
  End With
End Sub
 
Upvote 0
awesome !!
this really works (y)
much appreciated for your time and assistance ;)
 
Upvote 0
Actually I forgot the timestamp. Here is the final version:
VBA Code:
Sub addItem()
  Dim lRow As Long
  Dim lValue As Variant

  lRow = Worksheets("DETAILS").Cells(Rows.Count, 1).End(xlUp).Row
  With Worksheets("DETAILS")
    For i = lRow To 2 Step-1
      If .Cells(i, 2).Value = UserForm1.ComboBox1.Value And .Cells(i, 3).Value = UserForm1.ComboBox2.Value And .Cells(i, 4).Value = UserForm1.ComboBox3.Value Then
        lValue = .Cells(i, 5).Value - UserForm1.TextBox1.Value
        UserForm1.TextBox2.Value = lValue
        .Rows(i).Copy
        .Rows(i + 1). EntireRow.Insert
        .Cells(i + 1, 1).Value = Format(Now(), "dd/mm/yyyy")
        .Cells(i + 1, 5).Value = lValue
        Exit For
      End If
    Next
  End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,764
Messages
6,174,364
Members
452,558
Latest member
jswan83

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