【发布时间】:2016-08-12 15:30:27
【问题描述】:
如何动态扩展需要复制到另一张工作表的两列中的行数?
首先,我确定需要包含并存储在totrows 中的行数:
Dim totrows As Integer
With ThisWorkbook.Worksheets("Sheet1")
totrows = .Range("A" & .Rows.Count).End(xlUp).Row
End With
接下来,我尝试扩展感兴趣的两列(“B”和“G”),以便范围包括 totrows 行。对于一个静态示例,如果totrows=100 那么我会:
With ThisWorkbook.Worksheets("Sheet1")
.Range("B2:B102,G2:G102").copy
End With
然后我将它们粘贴到我的第二张表中:
ThisWorkbook.Worksheets("Sheet2").Range("A2").Paste
【问题讨论】:
-
谢谢!我一直在尝试
&没有运气 - 我一直把逗号放在引号之外(!)