Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel97--copy the last three rows of worksheet, paste in new book

Status
Not open for further replies.

MrsTFB

MIS
Oct 3, 2000
307
US
Hey guys,
It's me again, I'm almost there. Now I need the code to copy the last three rows of a workbook and paste them into another workbook.

I have the code to find the last row, which is working, I just don't know how to include the two preceding rows, copy the entire rows. I will be able to select the other workbook and paste the information there.

Thanks for your help,
Bsimm
 
Sub Macro2()
Dim sourceSheet, targetSheet As Object
Set sourceSheet = ActiveWorkbook.Sheets(1)
Set targetSheet = Workbooks(2).Sheets(2)
sourceSheet.Activate 'activate source sheet
Rows(ActiveCell.SpecialCells(xlLastCell).Row - 2 & ":" & ActiveCell.SpecialCells(xlLastCell).Row).Copy
targetSheet.Paste
End Sub

ide

ps. If you can do it from the keyboard or menu, the best way creating macros like this to "Record new macro" and edit that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top