[英]VBA Excel Paste to last empty cell
Here is my code it works fine for pulling data in. But I need more to pull in more data from another sheet to go in the last empty cell so I have all the data together. 这是我的代码,可以很好地提取数据。但是我还需要从另一个工作表中提取更多数据,以进入最后一个空单元格,因此我将所有数据都存储在一起。
Can I use the same code and change the name and just target the Paste to the last empty row? 我可以使用相同的代码并更改名称,然后将“粘贴”定位到最后一个空行吗?
Sub Run1()
Set wsInfoFrom = Worksheets("StowToPrimeWest")
Set wsInfoTo = Worksheets("View")
lastrow = wsInfoTo.Range("A" & wsInfoTo.Rows.Count).End(xlUp).Row
wsInfoTo.Range("A1:A" & lastrow).ClearContents
lastrow = wsInfoFrom.Range("A" & wsInfoFrom.Rows.Count).End(xlUp).Row
Set copyRange = wsInfoFrom.Range("A1:A" & lastrow)
copyRange.SpecialCells(xlCellTypeVisible).Copy wsInfoTo.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
Worksheets("View").Activate
End Sub
You can just clone that code and it will do what you want to do except for this line: 您可以只克隆该代码,它将执行您想做的事情,除了以下行:
wsInfoTo.Range("A1:A" & lastrow).ClearContents
which clears out everything from column A in the "View" sheet, so you should only do that once. 该操作清除了“视图”表中A列中的所有内容,因此您只能执行一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.