adapting code to merge amount for duplicates item on usrform

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
471
Office Version
  1. 2019
Hi
I would adapt @DanteAmor's code
VBA Code:
Option Explicit
Dim a As Variant

Private Sub TextBox1_Change()
  Call FilterData
End Sub



Sub FilterData()
  Dim txt1 As String, txt2 As String, txt3 As String
  Dim i As Long, j As Long, k As Long
 
  ListBox1.Clear
  ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))
  For i = 1 To UBound(a)
    If TextBox1 = "" Then txt1 = a(i, 4) Else txt1 = TextBox1
     Then
      k = k + 1
      For j = 1 To 7
        b(k, j) = a(i, j)
      Next
    End If
  Next
  If k > 0 Then ListBox1.List = b
End Sub

Private Sub UserForm_Activate()
  a = Sheets("purchase").Range("A2:G" & Sheets("purchase").Range("D" & Rows.Count).End(3).Row).Value
End Sub
I would when I write item in txtbox1 then should merge amount in column G for duplicates item.
and change the date column A to auto srial 1,2,3 when merging. but when clear then will return the original data as the original code does it.
thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
here is data
ABDO1.xlsm
ABCDE
1DATE CLIENT NOINVOICE NOBRANDBALANCE
201/05/2021CUS-BS-1INV-BS-11200R20 G580 JAP95.00
301/06/2021CUS-BS-1INV-BS-11200R20 G580 THI10.00
401/07/2021CUS-BS-1INV-BS-11200R20 G580 JAP5.00
501/08/2021CUS-BS-1INV-BS-11200R20 R187 THI10.00
601/09/2021CUS-BS-2INV-BS-21200R24 G580 JAP5.00
701/10/2021CUS-BS-2INV-BS-21200R20 G580 JAP30.00
801/11/2021CUS-BS-2INV-BS-21200R20 G580 THI50.00
901/12/2021CUS-BS-2INV-BS-21400R20 VSJ JAP12.00
1002/12/2021CUS-BS-2INV-BS-21400R20 R180 JAP13.00
purchase


and what I want when search in textbox based on column D
1.JPG
 
Upvote 0

Forum statistics

Threads
1,216,109
Messages
6,128,883
Members
449,477
Latest member
panjongshing

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