2016-08-11 3 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 
관련 문제