简体   繁体   English

Excel VBA:激活列中最后一个单元格之后的单元格

[英]Excel VBA: activate the cell after the last one in a column

Silly question: how do I go to the cell right after the last non-blank cell in column ? 愚蠢的问题:如何在列中最后一个非空白单元格之后立即转到该单元格? I can't figure it out for the life of me. 我无法终生解决。

I've tried something akin to: Range("A2", Range("A2").End(xlDown) + 1).Activate (A1 is blank) and Range("A2", Range("A2").End(xlDown + 1)).Activate , but it errors out. 我试过类似的东西: Range("A2", Range("A2").End(xlDown) + 1).Activate (A1为空白)和Range("A2", Range("A2").End(xlDown + 1)).Activate ,但出错了。

Thanks in advance! 提前致谢!

Use: 采用:

ActiveSheet.Cells(ActiveSheet.Rows.Count,1).End(xlup).Offset(1).Activate

NOTE: One should avoid .Activate and .Select These slow down code, but should directly use the reference. 注意:应该避免使用.Activate.Select这些减慢代码速度,但应直接使用引用。

See HERE for more information. 有关更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM