1

I have this code:

Workbooks("Test.xlsx").Worksheets("Sheet1").Range("A:D").RemoveDuplicates Columns:=1, Header:=xlNo

The problem is that if at least 1 duplicate is found it deletes the entire row.

I need something like this:

If (duplicate is found on on columns A & C) then delete entire row 

I mean delete the row where columns A has duplicates of above/below rows on it and also column C contains duplicates of above/below rows.

Any help would be appreciated! Thank you!

1
  • 1
    @Sid thats not an obvious solution, and would warrant an answer Commented Mar 26, 2020 at 7:18

1 Answer 1

1

Whenever in doubt, record a macro. To record a macro you may want to see Automate tasks with the Macro Recorder

When you are recording a macro, do this...

  1. Select your range
  2. Click on Data | Remove Duplicates.
  3. In remove duplicates dialog box, Click on Unselect all button.
  4. Click on Col A and Col C
  5. Click Ok

You will get a code which is something like this

YourRange.RemoveDuplicates Columns:=Array(1, 3), Header:=xlNo
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.