0

I am trying to delete duplicate rows from my table and I thought this was straightforward enough looking at other examples online. Unfortunately, I am getting a type mismatch error on my variable. Also, I want the first instance from the bottom to be deleted not the first instance. So if row 5 and 27 are duplicates, I want row 27 to be deleted.

Here is my code:

Sub DeleteDuplicateRows() Dim Rng As Range With Worksheets("Database") Set Rng = Range("C1", Range("Q1").End(xlDown)) Rng.RemoveDuplicates Columns:=Array(3, 17), Header:=xlYes End With End Sub 
1

1 Answer 1

2

Array(1, 15) is column C and column Q within range C:Q.

Sub DeleteDuplicateRows() Dim Rng As Range With Worksheets("Database") Set Rng = .Range("C1", .Range("Q1").End(xlDown)) Rng.RemoveDuplicates Columns:=Array(1, 15), Header:=xlYes End With End Sub 
Sign up to request clarification or add additional context in comments.

2 Comments

Is this making sure C and Q aren't duplicates or is it C or Q?
C and Q. If you want C or Q then you need to do it twice; once for C and once for Q.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.