user10101843
user10101843

Reputation: 41

Paste to the last empty row

My code generates an "application-defined or object-defined error" trying to paste to the last available row in the column.

sub pastelastrow()

Dim Dec18 As Worksheet
Dim wb As Workbook
Dim a As Long
Dim Template As Worksheet

Set wb = ThisWorkbook
Set Dec18 = wb.Sheets("Dec18")
Set Template = wb.Sheets("Template")

a = Dec18.Range("A" & Rows.Count).End(xlUp).Row

Dec18.Range("A1:C" & a).Copy_ 
Destination:=Template.Range("B1").End(xlDown).Offset(1, 0)

end sub

Upvotes: 0

Views: 65

Answers (1)

Dy.Lee
Dy.Lee

Reputation: 7567

Change like this.

Destination:=Template.Range("B" & rows.count).End(xlUp).Offset(1, 0)

Upvotes: 1

Related Questions