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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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