AutoFilter method of Range class failed setting criteria in VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brad Nerbovig
    New Member
    • Nov 2010
    • 5

    AutoFilter method of Range class failed setting criteria in VBA

    Greetings-

    I have AutoFilter turned on in my spreadsheet and am trying to set the criteria through VBA, but I'm continuing to get a method error. Here's the snippet of code:

    Code:
    Do While varUnit <> ""
         pvtResults.PivotFields("Unit Name").CurrentPage = varUnit
         shtPivot.ShowAllData
         shtPivot.Range("B12:I352").AutoFilter Field:=8, Criteria1:="<>0"
         intRow = intRow + 1
         varUnit = shtLists.Range("U" & intRow)
    Loop
    I even tried recording the macro and running it directly from that and I still get the same error. Any help would be appreciated.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Place a STOP just after and DIM statements you might have in the code. When you get into the Debugger, F8 thru the code until you get the error. This way we know exactly which line is causing the exception. All too often the code that we think is failing is ok and it's the line before.
    We'll also neen the error number and the description exactly as shown in the error message.

    Comment

    Working...