Hello,

I am trying to record a macro where I am using =LENS in column E to determine the total number of characters in column D. From there I am trying to filter out any results that <>4 so I can delete them and be left only with the rows that contain 4 characters. However whenever I get to the filtering portion of the code I receive an error before the deletion piece can occur. I am receiving the error message “Run-time error ‘1004’ Autofilter method of range class failed”. I have reviewed a number of posts on the subject but cannot seem to find any specific to my issue. Any thoughts on how I am receiving this error based on the portion of code I have listed below?

I have tried even changing the Range to only be for column E and continue to run into this same issue.

 Range("E1").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$F$1012").AutoFilter Field:=5, Criteria1:="<>4", _
        Operator:=xlAnd
    ActiveWindow.SmallScroll Down:=-12
    Rows("4:4").Select