Quick ? on deleting rows
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Quick ? on deleting rows

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I've got the delete rows thing working, deleting rows if a cell contains certain data. Now, how do I delete the row if the cell DOES NOT contain certain data? Thanks.

  2. #2
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default

    Hi! You mean like this?
    I am diffident in whether the code which I presented is filling your demand.
    Regards,

    Sub test()
    Dim i As Long, rngDel As Range
    For i = Cells.SpecialCells(xlCellTypeLastCell).Row To 1 Step -1
    If Application.WorksheetFunction.CountA(Rows(i)) = 0 Then
    If rngDel Is Nothing Then
    Set rngDel = Rows(i)
    Else
    Set rngDel = Union(rngDel, Rows(i))
    End If
    End If
    Next
    rngDel.EntireRow.Delete
    End Sub

  3. #3
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hi Dave

    I have many eaxmples of deleting rows to be found here. Most avoid the use of Loops as loops slow things down.
    http://www.ozgrid.com/VBA/VBACode.htm

    I also have a very quick method here:
    http://www.ozgrid.com/VBA/VBALoops.htm
    That does use a loop, but is sped up dramitically by dealing only with the cells needed.



User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com