I'm having an issue copying data to another sheet within the same workbook.
in the code provided the program works fine.
but anytime I try to change the copy destination to another sheet. I get an error. I did change the lastrow variable to the sheet that I was trying to copy to.
in the code provided the program works fine.
Code:
Sub dinocheck()
Dim i As Integer
Dim r2 As Integer
Dim lastrowdl, lastrowc, lastrowh, lastrowo, lcol As Long
lastrowdl = Sheets("dino list").Cells(Rows.Count, 1).End(xlUp).Row
lastrowc = Sheets("carnivore").Cells(Rows.Count, 1).End(xlUp).Row
lastrowh = Sheets("herbivore").Cells(Rows.Count, 1).End(xlUp).Row
lastrowo = Sheets("omnivore").Cells(Rows.Count, 1).End(xlUp).Row
lcol = Sheets("dino list").Cells(1, Columns.Count).End(xlToLeft).Column
For i = 2 To lastrowdl
If Sheets("dino list").Cells(i, 5).Value = "carnivore" Then
Sheets("dino list").Range(Cells(i, 1), Cells(i, lcol)).Copy Sheets("dino list").Range(Cells(lastrowdl + 1, 1), Cells(lastrowdl + 1, lcol))
End If
Next i
End Sub
but anytime I try to change the copy destination to another sheet. I get an error. I did change the lastrow variable to the sheet that I was trying to copy to.