PDA

View Full Version : [SOLVED:] Remove duplicates (runtime error 5)



nikki333
01-28-2018, 04:47 AM
Hi Forum,



Sub test()
Dim ws As Worksheet: Set ws = A99
ws.Range("A1: D454").RemoveDuplicates Columns:=Array(1, 2, 3, 4), Header:=xlYes
End Sub

Anybody an idea why this gives a runtime error 5. It' basically the same as the macro recorder did, which removed the duplicates
ActiveSheet.Range("$A$1:$D$454").RemoveDuplicates Columns:=Array(1, 2, 3, 4), Header:=xlYes

nikki333
01-28-2018, 06:19 AM
Update:
I found the problem was related to the Option Base 1 setting and resolved it like so:


ws.Range("A1: D454").RemoveDuplicates Columns:=VBA.Array(1, 2, 3, 4), Header:=xlYes