[英]Transfer data from one sheet to another
I transfer data from sheet "instru" to the sheet "data" using this code. 我使用此代码将数据从工作表“ instru”传输到工作表“ data”。
Option Explicit
Sub lastrow()
Dim wsS1 As Worksheet 'Sheet1
Dim wsS2 As Worksheet 'sheet2
Dim lastrow As Long
Set wsS1 = Sheets("Instru")
Set wsS2 = Sheets("data")
With wsS1
lastrow = range("A:A" & Rows.Count).End(xlUp).Row
wsS1.range("A5:KU5" & lastrow).Copy wsS2.range("A1:KU11440" & lastrow)
End With
End Sub
I want to achieve the same for a dynamic range. 我想在动态范围内达到相同的效果。 It should count the rows present in sheet "instru" and copy only that many rows to "data" sheet. 它应该计算工作表“ instru”中存在的行,并且仅将那么多行复制到“数据”工作表中。
Eg I want to copy ("A1:D1") based on the count of column "A" in "instru". 例如,我想基于“ instru”中“ A”列的计数进行复制(“ A1:D1”)。
Sub lastRow()
Dim wsS1 As Worksheet 'Sheet1
Dim wsS2 As Worksheet 'sheet2
Dim lastR As Long
Set wsS1 = Sheets("Instru")
Set wsS2 = Sheets("data")
With wsS1
lastR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A5:KU" & lastR).Copy wsS2.Range("A1")
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.