VBA Excel:如何删除2列中的重复项

时间:2023-02-14 04:18:09

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)

1 个解决方案

#1


6  

Remove the parenthesis when calling RemoveDuplicates if the function is not returning any value, like this:

如果函数没有返回任何值,则在调用RemoveDuplicates时删除括号,如下所示:

selection.RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes

#1


6  

Remove the parenthesis when calling RemoveDuplicates if the function is not returning any value, like this:

如果函数没有返回任何值,则在调用RemoveDuplicates时删除括号,如下所示:

selection.RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes