vba RemoveDuplicates 给出 1004 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15929896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 20:31:40  来源:igfitidea点击:

RemoveDuplicates gives 1004 error

excelvbaduplicates

提问by Marc

I want to remove duplicates from my selection, but this line gives me a 1004 error:

我想从我的选择中删除重复项,但这一行给了我 1004 错误:

ActiveSheet.Range("B3", Range("B3").End(xlDown)).RemoveDuplicates Columns:=2, Header:=xlNo

How do I fix this?

我该如何解决?

回答by Kazimierz Jawor

Change your line into:

将您的线路更改为:

ActiveSheet.Range(range("B3"), Range("B3").End(xlDown)).RemoveDuplicates Columns:=1, Header:=xlNo

or,if you really have 2 columns into:

或者,如果你真的有两列:

ActiveSheet.Range(range("B3"), Range("C3").End(xlDown)).RemoveDuplicates Columns:=2, Header:=xlNo