PDA

View Full Version : Delete duplicate rows based on 2 conditions using VBA Macro (Beginner)



alksndr
09-24-2016, 09:48 PM
Hi,

I have a data that looks like this:



Employee
Recipient
Response Received
Responses
Department
Job Title


PHMABI
Abadia, Maricel
---
Left Message
Billing
Analyst


PHMABI
Abadia, Maricel
---
No answer
Billing
Analyst


PHMABI
Abadia, Maricel
9/17/2015 12:31
I understand the message
Billing
Analyst


PHAABJ
Abando, Aileen
9/17/2015 11:01
I understand the message
CP
Analyst


PHAABJ
Abando, Aileen
---
Voicemail
CP
Analyst


PHMABD
Abarro, Marie
9/17/2015 10:34
I do not understand the message
Supplier
Specialist


PHMABD
Abarro, Marie
---
No answer
Supplier
Specialist



and from there, I would like to get the unique values using the Recipient column but also based on the response received column. Example:
Recipient - Abadia, Maricel with response time 9/17/2016 12:31 should remain and the other entries for Abadia, Maricel will be deleted.

Final output should look like this:



Employee
Recipient
Response Received
Responses
Department
Job Title


PHMABI
Abadia, Maricel
9/17/2015 12:31
I understand the message
Billing
Analyst


PHAABJ
Abando, Aileen
9/17/2015 11:01
I understand the message
CP
Analyst


PHMABD
Abarro, Marie
9/17/2015 10:34
I do not understand the message
Supplier
Specialist




Thank you in advance!

mana
09-24-2016, 10:04 PM
do you know advanced filter?
(Sorry, I don't know what that is called in english version)

mana
09-24-2016, 10:28 PM
Option Explicit


Sub test()
Dim r As Range 'Data table
Dim c As Range 'Criteria

Set r = Range("a1").CurrentRegion
Set c = r.Offset(, r.Columns.Count + 2).Resize(2, 1)
c.Value = [{"Response Received";"<>"}]

r.AdvancedFilter xlFilterInPlace, c, Unique:=True

c.ClearContents

End Sub