pivot table filter macro error

J

jras414

Hi All,

I am having some issues with a piece of code. every time we try to run this
macro, the program bugs up in the ElseIf statement. The error code is:

Run-time Error '5':
Invalid procedure call or argument.

If someone wouldn't mind just reading over the code to see if there are any
issues, it would be greatly appreciated!

Here is the code:

'Filter Pivots
For Each pt In ActiveSheet.PivotTables
For x = 1 To pt.PageFields.Count
If pt.PageFields(x) = trainingPageField Then
pt.PageFields(x).CurrentPage = filter
ElseIf pt.PageFields(x) = countPageField Then
*****ERROR @ NEXT LINE*****
--> pt.PageFields(x).CurrentPage = filter <--
If ActiveSheet.Name = sickLeaveSheet Then
Call FilterRegion
End If
End If
Next x
Next pt

Hopefully someone will be able to spot the issue. Please feel free to ask
for any clarifications.

Thank you in advanced

-Josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top