Consulting

Results 1 to 2 of 2

Thread: Delete Rows that meet a Criteria

  1. #1

    Delete Rows that meet a Criteria

    Hello,

    Please see the attached spreadsheet. I am trying to get a code to delete all rows that have the word "PDM" alone.

    Thanks
    Attached Files Attached Files

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    BTW, the word is "PDM "
    Sub PDM_DeleteLoneRows()
    'For help see: http://www.vbaexpress.com/forum/showthread.php?53069-Delete-Rows-that-meet-a-Criteria
    Dim Rw As Long
    Dim WsF As Object
      Set WsF = Application.WorksheetFunction
      
      Rw = Cells(Rows.Count, "I").Row
      With Columns("I")
        Do
          If Replace(.Cells(Rw).Value, " ", "") = "PDM" And WsF.CountA(Rows(Rw)) = 1 Then Rows(Rw).Delete
          Rw = Rw - 1
      Loop While Rw > 0
      End With
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •