简体   繁体   English

将数据从一张纸传输到另一张纸

[英]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”)。

Last Row Range 最后一行范围

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.

相关问题 VBA将数据从一张纸传输到另一张纸 - VBA Transfer of data from one sheet to another 将数据从工作表传输到另一工作表的 VBA 代码 - A VBA code to transfer data from a sheet to another one Excel 如何将数据从一张纸传输到另一张纸 - Excel how to transfer data from one sheet to another sheets Excel:数据从一张纸传输到另一张纸上的下一个空行错误 - Excel: transfer data from one sheet to next empty row on another sheet error VBA-根据文本将数据从一张纸传输到另一张纸,然后放入另一张纸的特定位置 - VBA- Transfer data from one sheet to another based on text and placing in into a specific location in the other sheet Excel VBA数据从一张纸转移到另一张纸错误仅标题复制没有任何数据 - excel vba data transfer from one sheet to another error only title copy no any data 根据Excel中的组合框值将数据从一张纸传输到另一张纸 - Transfer data from from one sheet to another based on combobox value in excel Excel VBA - 根据条件文本字符串将数据范围从一个工作表传输到另一个工作表 - Excel VBA - Transfer Data range from one sheet to another based on conditional text string 我想根据特定单元格中存在的行数将数据从一张纸转移到另一张纸 - I want to transfer data from one sheet to another based on the count of rows present in a particular cell 如何将特定数据从一张 excel 表传输到 MS Excel 中的另一张表? - How to transfer specific data from one excel sheet to another in MS Excel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM