So basically, I need to remove all records that don\'t have 3 as the 2nd digit in the primary key field which for example can either look like this
#39001
Try this instead:
Sub keep3()
Dim i As Integer
For i = 14000 To 2 Step -1
If Mid(Cells(i, 2), 2, 1) = "3" Then
Rows(i).EntireRow.Delete
End If
Next
End Sub
Note that the loop is going backwards - this is because when you delete a row, the row below gets pulled up, so your loop can do strange things if you go forwards and then delete a row, as you may skip over the next row that you may have also wanted to delete. Also, I changed the IF statement as you said you want to delete rows where the 2nd character is a 3.