vba 选择整列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35687541/
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-08 10:15:44  来源:igfitidea点击:

Select entire columns

excel-vbaselectmultiple-columnsvbaexcel

提问by R.Omar

I have a range activated Range(strPlageSélectionnée).Activate, and i'm looking for selecting their entire columns in order to delete them. I know that to select a column there is a specific formula ActiveCell.EntireColumn.Selectand to delete one column it's ActiveCell.EntireColumn.Delete

我有一个范围已激活Range(strPlageSélectionnée).Activate,我正在寻找选择它们的整个列以删除它们。我知道要选择一列有一个特定的公式ActiveCell.EntireColumn.Select并删除一列它是ActiveCell.EntireColumn.Delete

But how can i select and delete many columns at once. Is there any specific formula ?

但是我怎样才能一次选择和删除多列。有没有具体的公式?

Thanks for your help

谢谢你的帮助

回答by Dan Donoghue

Don't select columns to delete them, in fact you should rarely be selecting anything programmatically.

不要选择列来删除它们,实际上您应该很少以编程方式选择任何内容。

I suspect your columns are not next to each other so this will work.

我怀疑您的列彼此不相邻,因此这会起作用。

Range("C:C,F:F,I:I").Delete

Notice .select and selection were chopped off and the code combined to one line instead of:

注意 .select 和 selection 被砍掉了,代码合并到一行而不是:

Range("C:C,F:F,I:I").select
Selection.Delete

回答by crimmyjif

You can just replace ActiveCell with the Range.

你可以用 Range 替换 ActiveCell。

Range("C4:F10").EntireColumn.Delete