delete 8000 rows based on what I write items in helper column

Omran Y

New Member
Joined
Jul 17, 2023
Messages
39
Office Version
  1. 2013
Platform
  1. Windows
Hi
I want فخ delete entire row based on helper column (G) .should match the whole item for each cell in column G with column B then should delete entire row , but be careful you will see many similar items may be you think should delete it but in reality not . should match the whole item in column G with column B. if you see the part of item is existed in column B but not whole as in column G then should not delete it.
I have about 8000 rows and every time I will add new items in column G.

OM1.xlsm
ABCDEFG
1DATEOPERATION NAMEDEBITCREDITBALANCEITEMS
201/03/2023BB IN TPUT TTR120 CASH PREPAID10,000.0010,000.00CASH PREPAID
302/03/2023 PREPAID CASH BBI-60 IN TPUT MM2002,000.0012,000.00BANK SWIFT
403/03/2023BANK SWIFT FG-100530,000.0042,000.00INVOICE NUMBER SS
504/03/2023MS.9888485 BANK SWIFT FG-100160,000.00102,000.00
605/03/2023PAID BANK MTSWF900012,000.00100,000.00
706/03/2023 SWIFT BANK FGS-10010110,000.00110,000.00
807/03/2023 CASH PREPAID BBFG IN TPUT LM704030,000.00140,000.00
908/03/2023INN702000 CASH PIAD6,000.00134,000.00
1009/03/2023CASH PIAD MN90400 UY600M1,000.00133,000.00
1110/03/2023CASH FROM CURS 1200134,200.00
1211/03/2023CSDF SWIFT REF6789992000136,200.00
1312/03/2023CRTM RT500 CVF 789/77881300137,500.00
1410/03/2023INVOICE NUMBER SS OMM-10002300139,800.00
1511/03/2023INVOICE NUMBER SS OMM-10012200142,000.00
1612/03/2023INVOICE NUMBER SS OMM-10022500144,500.00
1713/03/2023INVOICE NUMBER RR OMM-10032800147,300.00
1814/03/2023INVOICE NUMBER RR OMM-10043100150,400.00
ACS


the output should be like this
OM1.xlsm
ABCDE
1DATEOPERATION NAMEDEBITCREDITBALANCE
202/03/2023 PREPAID CASH BBI-60 IN TPUT MM2002,000.0012,000.00
305/03/2023PAID BANK MTSWF900012,000.00100,000.00
406/03/2023 SWIFT BANK FGS-10010110,000.00110,000.00
508/03/2023INN702000 CASH PIAD6,000.00134,000.00
609/03/2023CASH PIAD MN90400 UY600M1,000.00133,000.00
710/03/2023CASH FROM CURS 1200134,200.00
811/03/2023CSDF SWIFT REF6789992000136,200.00
912/03/2023CRTM RT500 CVF 789/77881300137,500.00
1013/03/2023INVOICE NUMBER RR OMM-10032800147,300.00
1114/03/2023INVOICE NUMBER RR OMM-10043100150,400.00
OUTPUT
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Do you simply want the entire rows deleted from the "ACS" sheet (which could also delete the values in column G) or do you want the rows copied to another sheet ("OUTPUT"?) as you have indicated in your second image?
 
Upvote 0
Hi
I want showing result in OUTPUT sheet. I need keep the original data in first sheet.
Thanks .
 
Upvote 0
Try this?
Book5
ABCDEFGHIJKLM
1DATEOPERATION NAMEDEBITCREDITBALANCEITEMSDATEOPERATION NAMEDEBITCREDITBALANCE
201-Mar-23BB IN TPUT TTR120 CASH PREPAID10,000.0010,000.00CASH PREPAID02-Mar-23 PREPAID CASH BBI-60 IN TPUT MM2002,000.000.0012,000.00
302-Mar-23 PREPAID CASH BBI-60 IN TPUT MM2002,000.0012,000.00BANK SWIFT05-Mar-23PAID BANK MTSWF900010.002,000.00100,000.00
403-Mar-23BANK SWIFT FG-100530,000.0042,000.00INVOICE NUMBER SS06-Mar-23 SWIFT BANK FGS-10010110,000.000.00110,000.00
504-Mar-23MS.9888485 BANK SWIFT FG-100160,000.00102,000.0008-Mar-23INN702000 CASH PIAD0.006,000.00134,000.00
605-Mar-23PAID BANK MTSWF900012,000.00100,000.0009-Mar-23CASH PIAD MN90400 UY600M0.001,000.00133,000.00
706-Mar-23 SWIFT BANK FGS-10010110,000.00110,000.0010-Mar-23CASH FROM CURS 1,200.000.00134,200.00
807-Mar-23 CASH PREPAID BBFG IN TPUT LM704030,000.00140,000.0011-Mar-23CSDF SWIFT REF6789992,000.000.00136,200.00
908-Mar-23INN702000 CASH PIAD6,000.00134,000.0012-Mar-23CRTM RT500 CVF 789/77881,300.000.00137,500.00
1009-Mar-23CASH PIAD MN90400 UY600M1,000.00133,000.0013-Mar-23INVOICE NUMBER RR OMM-10032,800.000.00147,300.00
1110-Mar-23CASH FROM CURS 1,200.00134,200.0014-Mar-23INVOICE NUMBER RR OMM-10043,100.000.00150,400.00
1211-Mar-23CSDF SWIFT REF6789992,000.00136,200.00
1312-Mar-23CRTM RT500 CVF 789/77881,300.00137,500.00
1410-Mar-23INVOICE NUMBER SS OMM-10002,300.00139,800.00
1511-Mar-23INVOICE NUMBER SS OMM-10012,200.00142,000.00
1612-Mar-23INVOICE NUMBER SS OMM-10022,500.00144,500.00
1713-Mar-23INVOICE NUMBER RR OMM-10032,800.00147,300.00
1814-Mar-23INVOICE NUMBER RR OMM-10043,100.00150,400.00
Sheet1
Cell Formulas
RangeFormula
I2:M11I2=FILTER(A2:E18,NOT(MMULT(--ISNUMBER(SEARCH(TRANSPOSE(G2:G4),B2:B18)),SEQUENCE(ROWS(G2:G4),,,0))))
Dynamic array formulas.
 
Upvote 0
I like @Anonymous1378 's suggestion, however if you were after a VBA solution, please try this on a copy of your workbook:
VBA Code:
Option Explicit
Sub OmranY()
    Application.ScreenUpdating = False
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Worksheets("ACS"): Set ws2 = Worksheets("OUTPUT")
    
    Dim d As Object, c As Range, r As Range, tmp As String, a, b, LRow As Long, i As Long, j As Long
    LRow = ws1.Cells(Rows.Count, "G").End(xlUp).Row
    Set r = ws1.Range("G2:G" & Application.Max(LRow, 2))
    b = r.Value2
    If IsEmpty(b) Then MsgBox "No Items selected - exiting sub": Exit Sub
    
    If r.Cells.Count > 1 Then
        Set d = CreateObject("scripting.dictionary")
        a = Application.Transpose(ws1.Range("B2", ws1.Cells(Rows.Count, "B").End(xlUp)))
        For i = 1 To UBound(a, 1)
            d(a(i)) = 1
        Next i
        For Each c In ws1.Range("B2", ws1.Cells(Rows.Count, "B").End(xlUp))
            tmp = c.Value2
            For j = LBound(b) To UBound(b)
                If tmp Like "*" & b(j, 1) & "*" Then d.Remove (tmp)
            Next j
        Next c
    Else
        ReDim b(1 To 1, 1 To 1): b = r
    End If
    
    With ws1.Cells(1, 1).CurrentRegion
        If r.Cells.Count = 1 Then
            .AutoFilter 2, "<>" & "*" & b & "*"
        Else
            .AutoFilter 2, Array(d.keys), 7
        End If
        If ws1.Cells(Rows.Count, "A").End(xlUp).Row > 1 Then
            .Offset(1).Resize(.Rows.Count - 1, 5).Copy ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1)
        End If
        .AutoFilter
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
however if you were after a VBA solution, please try this on a copy of your workbook:
VBA Code:
yes, thanks .:)
I will test for simple data today , tomorrow at work for big data and come back to inform you how goes .;)
 
Upvote 0
I have about 8000 rows
If there are quite a few disjoint rows to delete in that range then I think that you may find this faster.

VBA Code:
Sub Del_Rows()
  Dim RX As Object
  Dim a As Variant, b As Variant
  Dim nc As Long, i As Long, k As Long
  
  Set RX = CreateObject("VBScript.regExp")
  RX.Pattern = "\b(" & Join(Application.Transpose(Range("G2", Range("G" & Rows.Count).End(xlUp)).Value), "|") & ")\b"
  nc = 6
  a = Range("B2", Range("B" & Rows.Count).End(xlUp)).Value
  ReDim b(1 To UBound(a), 1 To 1)
  For i = 1 To UBound(a)
    If RX.test(a(i, 1)) Then
      b(i, 1) = 1
      k = k + 1
    End If
  Next i
  If k > 0 Then
    Application.ScreenUpdating = False
    With Range("A2").Resize(UBound(a), nc)
      .Columns(nc).Value = b
      .Sort Key1:=.Columns(nc), Order1:=xlAscending, Header:=xlNo
      .Resize(k).EntireRow.Resize(, 6).Delete shift:=xlUp
    End With
    Application.ScreenUpdating = True
  End If
End Sub
 
Upvote 0
@Peter_SSs - I think you missed seeing Post #3
Thanks Alex, yes I did miss that - just saw the "delete rows" & fixed on that. 😎 :oops:

I don't have Excel 2013 to test this with but assuming OUTPUT exists and any data on it can be removed, this could be tried instead.

VBA Code:
Sub Remove_Rows()
  Dim rCrit As Range
  
  Sheets("OUTPUT").UsedRange.Clear
  With Sheets("ACS")
    Set rCrit = .Range("F1:F2")
    rCrit.Cells(2).Formula = "=COUNT(FIND(G$2:G$" & .Range("G" & Rows.Count).End(xlUp).Row & ",B2))=0"
    .Range("A1").CurrentRegion.Resize(, 5).AdvancedFilter Action:=xlFilterCopy, _
            CriteriaRange:=rCrit, CopyToRange:=Sheets("OUTPUT").Range("A1"), Unique:=False
    rCrit.ClearContents
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,024
Members
449,092
Latest member
ikke

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