PDA

View Full Version : Delete duplicate rows



reda
10-08-2016, 02:32 AM
Hi.
How to delete rows in a specific range by VBA
I.e
I want to delete duplicate rows in a table D10:K20.

mana
10-08-2016, 04:46 AM
you can use RemoveDuplicates method?

reda
10-08-2016, 04:54 AM
Can you give example.
I need a code to do that

mana
10-08-2016, 05:01 AM
This is what you want to do?


Option Explicit

Sub test()
Dim r As Range
Dim n As Long, i As Long
Dim col

Set r = Range("D10:K20")
n = r.Columns.Count - 1
ReDim col(0 To n)

For i = 0 To n
col(i) = i + 1
Next


r.RemoveDuplicates Columns:=CVar(col), Header:=xlNo

End Sub