Filtering Duplicates between 2 columns and removing rows

Watchdawg

Board Regular
Joined
Jan 21, 2015
Messages
84
Hopefully I can explain this properly. I need to gather data from a report which populates an excel spreadsheet.
As you can see in the example, there are 2 employees (the names are always bunched together), I need to remove any duplicate times by employee as shown in my example. Once that's complete, I need to remove any rows that contain a blank cell in both D and E side by side (both must be blank).
example.png
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Please try the following on a copy of your workbook:
VBA Code:
Option Explicit
    Sub ScrubDub()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, a, i As Long
    Set ws = Worksheets("Sheet1")       '<-- *** Change to actual sheet name ***
    a = ws.Range("A1", ws.Cells(Rows.Count, "E").End(xlUp))
    
    For i = 1 To UBound(a, 1) - 1
        If a(i, 5) = a(i + 1, 4) And a(i, 2) = a(i + 1, 2) Then
        a(i, 5) = "": a(i + 1, 4) = ""
        End If
    Next i
    ws.Range("A1").Resize(UBound(a, 1), UBound(a, 2)).Value = a
    
    For i = UBound(a, 1) To 1 Step -1
        If a(i, 4) = "" And a(i, 5) = "" Then ws.Rows(i).Delete
    Next i
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,149
Members
449,098
Latest member
Doanvanhieu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top