Excel VBA 用于从特定单元格开始选择整列

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

Excel VBA for selecting an entire column starting from a specific cell

excel-vbavbaexcel

提问by czchlong

How do I select the entire column after a specific cell?

如何在特定单元格后选择整列?

For example, I would like to select the entire column after C24so that includes C24, C25, ...

例如,我想在之后选择整个列,C24以便包括C24, C25, ...

I have worked with the following snippet with no success:

我使用了以下代码段但没有成功:

ActiveSheet.Range("C24", ActiveSheet.Range("C24").End(xlDown)).Select

Could someone please correct my error?

有人可以纠正我的错误吗?

回答by A. Webb

You just need to wrap the two references within a Range:

您只需要将两个引用包装在 a 中Range

Range(ActiveSheet.Range("C24"), ActiveSheet.Range("C24").End(xlDown)).Select

回答by Doug Glancy

Here's an approach that will work even if there are cells with content below C24:

这是一种即使存在内容低于 C24 的单元格也能工作的方法:

With ActiveSheet
.Range(.Range("C24"), .Range("C" & .Rows.Count)).Select
End With

回答by Jeremiah

i don't know if you want a formula for it or if any method will work but if you select the cell you want it to start on and hold ctrl+shift+down arrow it will select that cell and everything below it.

我不知道你是否想要一个公式或者是否有任何方法可以工作但是如果你选择你想要它开始的单元格并按住 ctrl+shift+向下箭头它会选择那个单元格和它下面的所有内容。