2014-10-01 106 views

回答

0

在VBA和与该实例中,以下假设:

你的数据是在Sheet开始在B12

你的提取数据组被复制到Sheet开始B12

如果有少比50行数据复制所有行

您可以配置这些参数。

Sub CopyLast50() 

Dim lRow As Long, sRow As Long 
Dim lCol As Long, sCol As Long 
Dim numRows As Long 

'Configure these parameters 
lCol = 6 
sCol = 2 
sRow = 12 
numRows = 50 

    With Sheets("Sheet1") 
     lRow = .Cells(Rows.Count, sCol).End(xlUp).Row 
      If sRow + lRow >= numRows Then 
       .Range(.Cells(lRow, sCol).Offset(-(numRows - 1), 0), .Cells(lRow, lCol)).Copy _ 
       Destination:=Sheets("Sheet2").Cells(sRow, sCol) 
      Else 
       .Range(.Cells(sRow, sCol), .Cells(lRow, lCol)).Copy _ 
       Destination:=Sheets("Sheet2").Cells(sRow, sCol) 
      End If 
    End With 

End Sub 

请花些时间阅读本网站的参考资料,可在帮助下找到。

相关问题