Delete Unwanted Rows
- zmagic
- Thread is marked as Resolved.
-
-
-
-
Hi zMagic,
faster variation if you have thousands of rows to delete.
Code
Display MoreOption Explicit Sub ptest() Dim dRange As Range Dim dRow As Long For dRow = 1 To Cells(Rows.Count, "C").End(xlUp).Row If Not Cells(dRow, "C") Like "CCODE -/00###/*" Then If dRange Is Nothing Then Set dRange = Cells(dRow, "C") Else Set dRange = Union(dRange, Cells(dRow, "C")) End If End If Next dRow If Not dRange Is Nothing Then dRange.EntireRow.Delete End Sub
-
Even faster, assumes header row is Row 1 and starts in Column A
Code
Display MoreSub DeleteRows() Dim x, i& With ActiveSheet.Cells(1).CurrentRegion x = .Value For i = 2 To UBound(x, 1) If Not x(i, 2) Like "*CCODE -/00###*" Then x(i, 1) = vbNullString Next .Value = x On Error Resume Next .Columns(1).SpecialCells(4).EntireRow.Delete On Error GoTo 0 End With End Sub
-
hi all
how to delete rows based on cell value ?
thanks
-
-
mamaraziz, please ask your question in a new thread
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!