Camera Icon

Got an event that needs shooting?  I've covered multiple events for marathon-photos.com and can capture the scenes & emotions that make your event unique.

Some samples of my own work are at Digital Formula on Flickr.

Wand Icon

Do you or your business need a website but you're unsure where to start?  Get in touch now and we'll get it sorted.

I focus on usable functionality & can setup smaller sites using Wordpress within hours of the order being placed.  Magic!

Globe Icon

So, you've already got a website but need help managing it?  I can help you.

Don't worry about knowing every single detail.  I'll find out the most important stuff and work with you to reach your goal, not someone else's.

said on twitter: LOL spammers really do bank on the ignorance of their targets huh? A file with a .jpg.exe extension ... really? http://t.co/0TgobjQc

 
Short URL
Warning: This article is older than 180 days and may contain inaccurate information.  Please use the information below at your own risk.

Microsoft Excel - Delete duplicate rows

I've been meaning to put this online for some time but kept forgetting to get it done.  This article is simple and provides a small Excel VBA script that makes it easy to delete duplicate rows from an Excel worksheet.

All you need to do is copy the code into an Excel module or class, depending on how your Excel application works.  Then you just provide the relevant row ranges and the script will do the rest.

Sub DeleteDuplicateRows()
    ' Chris Rasmussen January 2011
    ' DeleteDuplicates
    '   goes through the range specified below and, if a duplicate value is found anywhere in the range, deletes that value's entire row
    '
    Dim x As Long
    Dim LastRow As Long
    Dim duplicateCount As Integer
    
    duplicateCount = 0
     
    LastRow = Range("A300").End(xlUp).Row
    For x = LastRow To 1 Step -1
        If Application.WorksheetFunction.CountIf(Range("A1:A" & x), Range("A" & x).Text) > 1 Then
            Range("A" & x).EntireRow.Delete
            duplicateCount = duplicateCount + 1
        End If
    Next x
    If duplicateCount > 0 Then
        Results = MsgBox(duplicateCount & " duplicate rows removed.", vbInformation, "Duplicate rows")
    Else
        Results = MsgBox("No duplicate rowsfound.", vbInformation, "Duplicate rows")
    End If
End Sub

Easy.  :-)

» Tags: excel, vba, report, reports, reporting, delete row, duplicate row
DigitalFormula is an experiment in HTML5 and CSS3 design by Chris Rasmussen, an amateur/casual designer based in Melbourne, Australia. -37.813611 144.963056