Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 将一系列单元格复制到新工作表_Vba_Excel - Fatal编程技术网

Vba 将一系列单元格复制到新工作表

Vba 将一系列单元格复制到新工作表,vba,excel,Vba,Excel,我试图将一系列数据(不断更新)复制到另一张工作表中的下一个空行,以便永久存储。 我的代码可以工作,但它只复制第一行,我需要它复制9行的范围。 提前谢谢 Sub Export() Dim Timestamp As Date Dim lastrow As Integer Dim raw_data As Variant 'Records all data to DBO Timestamp = Now raw_data = Sheets("Data").Range("A2:M10").Value

我试图将一系列数据(不断更新)复制到另一张工作表中的下一个空行,以便永久存储。 我的代码可以工作,但它只复制第一行,我需要它复制9行的范围。 提前谢谢

Sub Export()

Dim Timestamp As Date
Dim lastrow As Integer
Dim raw_data As Variant

'Records all data to DBO

Timestamp = Now
raw_data = Sheets("Data").Range("A2:M10").Value
        lastrow = Sheets("DBO").Range("B60000").End(xlUp).Row
        Sheets("DBO").Range("A" & lastrow + 1) = Timestamp
        Sheets("DBO").Range("B" & lastrow + 1, "N" & lastrow + 1).Value = raw_data
        Workbooks("Board.xlsm").Save

End Sub

“N”和lastrow+1
更改为
“N”和lastrow+9
就这么简单。。。谢谢你的帮助!
raw_data = Sheets("Data").Range("A2:M10").Value

With Sheets("DBO").Range("B60000").End(xlUp).Offset(1,0).EntireRow

    .Cells(1).Value = Timestamp

    'If you set the destination range using the upper bounds of
    '   raw_data then you don't have to edit this line if you 
    '   change your input range from A2:M10 to something a different size
    .Cells(2).Resize(UBound(raw_data,1),UBound(raw_data,2)) = raw_data

End With

Workbooks("Board.xlsm").Save