(Solved) – Excel VBA Autofilter Error Message Using Strings & Integer

(solved)-–-excel-vba-autofilter-error-message-using-strings-&-integer

Can someone please help me get past this error. I didn’t build the excel sheet or VBA module, but I’ve been tasked to update it and I’m stuck. The code is below. I’m getting an error on the code in BOLD, which is:

Sheets(X).Columns(X).Autofilter_
Field:=F

(See full expression below)


Sub Reset_Search()

    Dim Str As String
    Dim X As Integer
    Dim Sheetcount As Integer

    Str = ActiveSheet.Name
        Sheetcount = ActiveWorkbook.Sheets.Count
            For X = 2 To Sheetcount
                For F = 1 To 16
                    If F = 1 Then Column = "A"
                    If F = 2 Then Column = "B"
                    If F = 3 Then Column = "C"
                    If F = 4 Then Column = "D"
                    If F = 5 Then Column = "E"
                    If F = 6 Then Column = "F"
                    If F = 7 Then Column = "G"
                    If F = 8 Then Column = "H"
                    If F = 9 Then Column = "I"
                    If F = 10 Then Column = "J"
                    If F = 11 Then Column = "K"
                    If F = 12 Then Column = "L"
                    If F = 13 Then Column = "M"
                    If F = 14 Then Column = "N"
                    If F = 15 Then Column = "O"
                    **Sheets(X).Columns(X).AutoFilter _
                        Field:=F**
                Next F
            Next X

    Sheets(Str).Activate

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *