I am trying to remove duplicates having variable information.

  • Column F = delete time
  • Column Q = recipient code
  • Column R = recipient address

I need to remove duplicates that match on row information. What defines a duplicate is column F, which can vary by up to 15 minutes. The difficulty for me is that there are hundreds of line items that match Column Q & R. So I sort by column F and then I am forced to look line-item by line-item at columns Q & R, which is very time consuming. Any help is greatly appreciated!

  • Can you include some sample data for us to work with?
    – Burgi
    Feb 20, 2020 at 9:26

1 Answer 1


I would like to suggest two possible method.

First is, built-in command should work.

  • Select columns one by one (since are not in continuation) and from Data TAB, choose Remove duplicates.
  • On the Remove duplicates window you may Check and Un-check columns.
  • Click OK and it should remove the duplicates from the selected columns.

enter image description here

Second method is, VBA Macro, is faster and better.

Sub RemoveDuplicateSpecificColumns() 

Cells.RemoveDuplicates Columns:=Array(1, 4, 7), Header:=xlYes

End Sub

How it works:

  • To open the VB Editor, either hit Alt+F11 or Right Click the Sheet TAB.
  • Then click View Code.
  • Copy & Paste this code as standard module.
  • Save the Workbook as Macro enabled.
  • RUN the Marco.


In above code Array(1, 4, 7) represents Column 1st, 4th & 7th, you need to adjust them as your need.

Header:=xlYes should Header:=XlNo, if column has no header.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.