Results 1 to 1 of 1

autofilter method of range class failed -header has tables headers and non table headers

Threaded View

  1. #1
    Registered User
    Join Date
    10-13-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2003
    Posts
    1

    autofilter method of range class failed -header has tables headers and non table headers

    HI

    I am consolidating data from different workbooks to a single sheet.
    In the WSR Consolidation excel, in the ‘LIST’ sheet I have created a Name ‘CritList with filter details.

    I am filtering multiple data rows.
    Columns A,B and C are normal columns but Column D and E are tables.
    Column D and E are tables since there are formulas defined for Dependent drop down.

    I am getting an error
    Run time error 1004 autofilter method of range class failed

    Please find the code and sample file.

    Please suggest how to resolve the issue.

    Option Explicit
    Sub pro2007FileSearchA()
    Dim varPath
    Dim varFile
    Dim varThatWorkbook
    Dim varNbRowsIn
    Dim varNbcolsIn
    Dim varNbRowsDatabase
    Dim vCrit As Variant
    Dim wsO As Worksheet
    Dim wsL As Worksheet
    Dim rngCrit As Range
    Dim rngOrders As Range
    Dim pw As String
    Dim rng As Range
    
    
        varPath = ThisWorkbook.Path & "\"
        varFile = Dir(varPath & "WSR_Horizon*.xlsm")
        
        ThisWorkbook.Activate
        Range("A1").Select
        Rows("2:" & Rows.Count).ClearContents
        
        Set wsL = Worksheets("Lists")
        Set rngCrit = wsL.Range("CritList")
    
        vCrit = rngCrit.Value
           
        Do While varFile <> ""
                    Application.DisplayAlerts = False
                    Workbooks.Open varPath & varFile
                    varThatWorkbook = ActiveWorkbook.Name
                    
                    Set wsO = Worksheets("WSR-HZN")
                    wsO.Unprotect Password:=pw
                    
                    Set rngOrders = wsO.Range("$A$1").CurrentRegion
                                    
                    rngOrders.AutoFilter _
                    Field:=1, _
                    Criteria1:=Application.Transpose(vCrit), _
                    Operator:=xlFilterValues
                    
                    Set rng = Selection.Offset(1, 0).Resize(Rows.Count - 1, Columns.Count) _
                          .SpecialCells(xlCellTypeVisible)
                    rng.Copy
                   
                    ThisWorkbook.Activate
                    Range("A1").Select
                    varNbRowsDatabase = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
                    ActiveCell.Offset(varNbRowsDatabase, 0).Select
                    Selection.PasteSpecial xlPasteValues
                    Application.CutCopyMode = False
                    Windows(varThatWorkbook).Activate
                    wsO.Protect Password:=pw
                    ActiveWorkbook.Close
                    varFile = Dir
                    Application.DisplayAlerts = True
            Loop
            
            ThisWorkbook.Activate
            Range("A1").Select
            ActiveWorkbook.Save
            'Workbooks("Release_Weekof_Dropdown.xlsx").Close SaveChanges:=False
    End Sub
    Regards,
    Naveen N
    Last edited by naveen.acheanz; 06-16-2016 at 08:24 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Autofilter Method of Range class failed
    By rmrjr22 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-30-2015, 11:18 AM
  2. Autofilter method of range class failed when <> contain
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2015, 05:02 PM
  3. [SOLVED] Autofilter method of Range Class Failed
    By slamdunka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2015, 03:24 AM
  4. AutoFilter Method Of Range Class Failed
    By goss in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-10-2015, 09:40 PM
  5. Autofilter Method of Range Class Failed
    By goss in forum Excel General
    Replies: 1
    Last Post: 04-05-2012, 11:44 AM
  6. AutoFilter method of Range class failed - Yet autofilter works.
    By Carlsbergen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2009, 05:43 PM
  7. Autofilter method of range class failed
    By Terry K in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-17-2005, 11:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1