Delete Unwanted Rows

  • HI,

    I want to delete un-required rows from my workbook and those with CCODE -/00***/ must stay and other rows to get deleted.

    There are more than 1000 rows and I want to clean them up.

    Quote

  • Assume your data is in columns A, B and C. Here is a VBA solution


    Code
    Sub Foo
    Dim lr as long, i as long
    lr = Range("A" & rows.count).end(xlup).row
    For i = lr to 2 step -1
    If Instr(Range("C" & i), "CCODE -/00") = 0 then
    Range("C" & i).EntireRow.Delete
    End If
    Next i
    End Sub
  • Hi zMagic,

    faster variation if you have thousands of rows to delete.

  • Even faster, assumes header row is Row 1 and starts in Column A

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

    Edited 2 times, last by KjBox ().

  • mamaraziz, please ask your question in a new thread

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!