简体   繁体   English

如何 select VBA 中的一系列单元格?

[英]How to select a range of cells in VBA?

I wrote a bunch of SAP scripting code that works great and here comes (as usual) one of those issues that make no sense whatsoever.我编写了一堆运行良好的 SAP 脚本代码,但(像往常一样)出现了一个毫无意义的问题。

So, I've tried two lines of code so far and about 500 variations of those two.所以,到目前为止,我已经尝试了两行代码以及这两者的大约 500 种变体。 In both cases, I get "Application-defined or object-defined error."在这两种情况下,我都会收到“应用程序定义或对象定义错误”。

ThisWorkbook.Worksheets(7).Range(Cells(3, 1) & Cells(3, 1).End(xlDown)).Copy
ThisWorkbook.Worksheets(7).Range("A3:" & Range("A3").End(xlDown)).Copy

I simply want to select from A3 all the way down as far as the data goes.就数据而言,我只是想从 A3 一直到 select。 Can it get any simpler than that?能比这更简单吗?

The solution was to actually specify that the last row is the Address.解决方案是实际指定最后一行是地址。 Mind.头脑。 Blown.吹。

Range("A3:" & Range("A1048576").End(xlUp).Address).Copy

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

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