(Solved) – While debugging VBA code, i am getting an erorr saying “Object required for the 8th line

  • by
Sub copyNonblankData()

Dim erow As Long, lastrow As Long, i As Long

lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row

For i = 2 To lastrow

    If Sheet1.Cells(i, 1) <> "" Then
    ' i'm assuming the next line is the 8th line?
    Sheets("Sheet1").Range(Cells(i, 1), Cells(i, 2)).Copy
    ' error occurs here
    erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row.Offset(1, 0).Row
    ActiveSheet.Paste Destination:=Sheets("Sheet2").Range(Cells(erow, 1), Cells(erow, 2))
    End If

Next i

Application.CutCopyMode = False

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *