AMRG2013
06-15-2013, 10:50 AM
The code below copies Range (D13:Q100) of workbook2.xls to the workbook1.xls (this workbook), in Range (D13:Q100). And it works fine!
What I want is to copy only the last 10 rows of workbook2.xls, within that range (D13:Q100), to this workbook1.xls.
How can I do this?
thank you
Sub GetDataFromClosedWorkbook()
Dim wb As Workbook
Application.ScreenUpdating = False ' turn off the screen updating
Set wb = Workbooks.Open("D\Work\Workbook2.xls", True, True)
' open the source workbook, read only
With ThisWorkbook.Worksheets("Results")
' read data from the source workbook
.Range("D13:100").Formula = wb.Worksheets("Data").Range("D13:Q100").Formula
End With
wb.Close False ' close the source workbook without saving any changes
Set wb = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating
End Sub
What I want is to copy only the last 10 rows of workbook2.xls, within that range (D13:Q100), to this workbook1.xls.
How can I do this?
thank you
Sub GetDataFromClosedWorkbook()
Dim wb As Workbook
Application.ScreenUpdating = False ' turn off the screen updating
Set wb = Workbooks.Open("D\Work\Workbook2.xls", True, True)
' open the source workbook, read only
With ThisWorkbook.Worksheets("Results")
' read data from the source workbook
.Range("D13:100").Formula = wb.Worksheets("Data").Range("D13:Q100").Formula
End With
wb.Close False ' close the source workbook without saving any changes
Set wb = Nothing ' free memory
Application.ScreenUpdating = True ' turn on the screen updating
End Sub