I'm trying to write a code that first find the last row, and selects all rows between the 2nd to last row and the 3rd row. Then proceeds to delete them. But I keep running into an error 13 : Type mismatch
Dim StartRow, LastRow, NuRow As Variant
StartRow = 3
Sheets("Sheet3").Activate
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
End If
NuRow = LastRow - 1
Rows("StartRow:NuRow").Delete 'Run time error 13 Type Mismatch
Any ideas ?
It is the Rows object that is throwing the error. It is expecting a row Index in the form "3:20" (for example). You are passing it a string "StartRow:NuRow".
Try changing that statement to:
Try this instead: