0
Sub Macro1()

Dim lr As Long
Dim i As Integer

Range("a20:ab20").Copy
    
Workbooks.Open Filename:="C:\Users\max.murrell\Documents\Coventry Gateway South\Tracking\Main\master tracking sheet.xlsm"
    
Workbooks("master tracking sheet.xlsm").Activate
Sheets("Recieved Results").Select
    
i = Worksheets("Recieved Results").cells(Rows.Count, 1).End(xlUp).Rows.Offset(1, 0)
cells(i + 1).PasteSpecial
Application.CutCopyMode = False

End Sub

Hi, im trying to paste on the last line in another work book. it is currently pasting on the first line. i dont believe my counter is right but im not sure why its not right. i have checked online but ive come to a bit of a brick wall. any help would greatly appreciated. thanks in advance max

SJR
  • 22,986
  • 6
  • 18
  • 26
  • it's best practice - and a lot of cases, absolutely necessary, to explicitly refer to the objects you are working with. Things like `Range(...`) and `Rows.Count` and `Cells(..` need to refer to the specific parent object. So, tie them directly to the worksheet/workbook, etc. [Avoid Using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – Scott Holtzman Aug 13 '20 at 16:58
  • Also it should be `i = Worksheets("Recieved Results").cells(Rows.Count, 1).End(xlUp).Offset(1, 0).row`. – SJR Aug 13 '20 at 17:01
  • Hi SJR, thnaks so much for your help i got it to work. i implemented your advice and it started pasting the data in the first row, so i change cells to rows and i got the data to start pasting in the right row. Thank you so much for help couldnt of done it without you. – Max Murrell Aug 13 '20 at 17:58

0 Answers0