I keep getting "Subscript out of range" run time error code 9 on this code where indicated
Can anyone see any reason why ?
Thanks for anyone's help
cr
Code:
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
Sheets(“Sheet1”).Range(Cells(i, 1), Cells(i, 2)).Copy - Subscript out of range error at this line
Sheets(“sheet2”).Activate
erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Sheets(“sheet2”).Range(Cells(erow, 1), Cells(erow, 2))
Sheets(“sheet1”).Activate
End If
Next i
Application.CutCopyMode = False
End Sub
Can anyone see any reason why ?
Thanks for anyone's help
cr