+ Reply to Thread
Results 1 to 3 of 3

Delete entire row based on 2 criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    Mesquite, Texas, USA
    MS-Off Ver
    Excel 2010
    Posts
    48

    Delete entire row based on 2 criteria

    I'm trying to write a macro to delete an entire row only if all cells are blank and all cells have colorindex = 15. The sheet is 40 rows long and 10 columns wide, with some cells at the bottom of the list highlighted yellow. The problem I'm having is that it deletes rows until it reaches a point where all columns contain data. I need I need it to just delete the rows below the longest list.
    Last edited by coopman64; 11-13-2012 at 03:25 PM. Reason: clarify post

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Delete entire row based on 2 criteria

    Try this...

    Sub Delete_Rows()
        
        Dim i As Long, cell As Range, counter As Long
        
        Application.ScreenUpdating = False
        For i = 40 To 1 Step -1
            With Range("A" & i & ":J" & i)
                If Application.WorksheetFunction.CountBlank(.Cells) = .Count Then
                    counter = 0
                    For Each cell In .Cells
                        If cell.Interior.ColorIndex <> 15 Then Exit For Else counter = counter + 1
                    Next cell
                    If .Count = counter Then Rows(i).Delete
                End If
            End With
        Next i
        Application.ScreenUpdating = True
        
    End Sub

  3. #3
    Registered User
    Join Date
    10-09-2012
    Location
    Mesquite, Texas, USA
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Delete entire row based on 2 criteria

    Works like a charm! Exactly what I needed.
    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1