Results 1 to 11 of 11

Macro Delete Duplicate Rows with Exception

Threaded View

  1. #1
    Registered User
    Join Date
    06-15-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2003
    Posts
    23

    Question Macro Delete Duplicate Rows with Exception

    I am creating a macro to delete rows based on a duplicate value in column E (see code below). However, there are times that I signify a blank cell with "--", in these instances I would like to not delete those rows because there is other information that is needed. Thanks for your help in advance.

    Private Sub RemoveDuplicateRowsSR()
    
    Dim rCell As Range
        Dim rRange As Range
        Dim lCount As Long
         
        Set rRange = Range("E8", Range("E" & Rows.Count).End(xlUp))
        lCount = rRange.Rows.Count
         
        For lCount = lCount To 1 Step -1
            With rRange.Cells(lCount, 1)
                If WorksheetFunction.CountIf(rRange, .Value) > 1 Then
                    .EntireRow.Delete
                End If
            End With
        Next lCount
    
    End Sub
    Last edited by arlu1201; 06-15-2012 at 10:57 AM. Reason: Code tags

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