By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 1,964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

AutoFilter method of Range class failed setting criteria in VBA

P: 5

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:

Expand|Select|Wrap|Line Numbers
  1. Do While varUnit <> ""
  2.      pvtResults.PivotFields("Unit Name").CurrentPage = varUnit
  3.      shtPivot.ShowAllData
  4.      shtPivot.Range("B12:I352").AutoFilter Field:=8, Criteria1:="<>0"
  5.      intRow = intRow + 1
  6.      varUnit = shtLists.Range("U" & intRow)
  7. 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.
Sep 17 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 5,397
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.
Sep 18 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.