Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi Good morning, I hope you can help me I have a command button once clicked on it should archive the old data that has 'delivered' in a cell. But I get an error 'Run time error 9 - subscript out of range' on the line below, please also see the whole code below, hope you can help.
Code:
lastrow = Sheets(“projects”).Range(“A” & Rows.Count).End(xlUp).Row
Code:
Sub archive()
Dim i, lastrow
Dim mytext As String
lastrow = Sheets(“projects”).Range(“A” & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
mytext = Sheets(“projects”).Cells(i, “C”).Text
If InStr(mytext, “delivered”) Then
Sheets(“projects”).Cells(i, “A”).EntireRow.Copy Destination:=Sheets(“delivered”).Range(“A” & Rows.Count).End(xlUp).Offset(1)
Sheets(“projects”).Cells(i, “A”).EntireRow.Delete
End If
Next i
End Sub