What would cause this line
If Cells(i, 3) = "" Or VBA.Left(Cells(i, 3), 5) = "BIGA-" Or VBA.Left(Cells(i, 3), 5) = "BRNG-" Or VBA.Left(Cells(i, 3), 5) = "ENER-" Or VBA.Left(Cells(i, 3), 5) = "EURE-" Or VBA.Left(Cells(i, 3), 5) = "STRE-" Then Rows(i).Delete
in the below macro to return a Run-Time Error ’13’ Type Mismatch after the first cell record is found and deleted?
Option Explicit
Sub deletedExceptions_row()
Dim i As Long
For i = Cells.SpecialCells(xlCellTypeLastCell).Row To 1 Step -1
If Cells(i, 3) = "" Or
VBA.Left(Cells(i, 3), 5) = "BIGA-" Or
VBA.Left(Cells(i, 3), 5) = "BRNG-" Or
VBA.Left(Cells(i, 3), 5) = "ENER-" Or
VBA.Left(Cells(i, 3), 5) = "EURE-" Or
VBA.Left(Cells(i, 3), 5) = "STRE-" Then
Rows(i).Delete
Next i
End Sub
Try this
Now does it give an error? If it does then what is the value of
i. If the value ofiis say 17 then check the cell C17. I am sure there is a formula in that cell which is giving an error. For example#DIV/0!or any other error. It is only in this scenario will it give atype mismatch error.SNAPSHOT