2016-08-11 103 views
1

我試圖將一系列數據(即不斷更新的)複製到不同工作表中的下一個空行以進行永久存儲。 我的代碼將工作,但它只會複製第一行,我需要它複製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 
+1

變化' 「N」 與LASTROW + 1'到' 「N」 與LASTROW + 9'​​ –

+0

就這麼簡單......感謝您的幫助! – Josh

回答

1
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 
相關問題