Reputation: 6196
I have the following below, but I'm having issues with the syntax. I want to set the current selection as a range, and I want to remove duplicates from that selection. How can I do this?
'remove duplicates
Columns("B:C").Select
Dim duplicates As Range
Set duplicates = Selection
ActiveSheet.duplicates.RemoveDuplicates(Columns:=Array(1, 2), Header:=xlYes)
Upvotes: 4
Views: 34615
Reputation: 98
Remove the parenthesis when calling RemoveDuplicates if the function is not returning any value, like this:
selection.RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
Upvotes: 8