allstarrunner
New Member
- Joined
- May 29, 2012
- Messages
- 34
Hi, and thank you for your help,
This is the code I have (which I found on another forum, and it works great for calling on one value), but I need it adjusted so the Range “B3” can be called upon using a named range I set; or, in other words, to call on multiple values to filter in the pivot table, instead of just one i.e. B3:B8, then all 6 of those will show in the pivot table.
The error I get right now is a Type mismatch with the ‘filterCost’, which I assume has something to do with filterCost being defined as a String, but don’t really know. Thanks.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
></o
>
<o
>
</o
>
This is the code I have (which I found on another forum, and it works great for calling on one value), but I need it adjusted so the Range “B3” can be called upon using a named range I set; or, in other words, to call on multiple values to filter in the pivot table, instead of just one i.e. B3:B8, then all 6 of those will show in the pivot table.
The error I get right now is a Type mismatch with the ‘filterCost’, which I assume has something to do with filterCost being defined as a String, but don’t really know. Thanks.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
<o
Rich (BB code):
Rich (BB code):
Rich (BB code):
</o:p>
Sub Apply_Cost_Filter()
Dim pvtTable As PivotTable
Dim pvtField As PivotField
Dim pvtItem As PivotItem
Dim filterCost As String
Set pvtTable = Worksheets("Pivot_Sheet").PivotTables("PivotTable1")
Set pvtField = pvtTable.PivotFields("Cost")
filterCost = Worksheets("Controls_Sheet").Range("B3")
For Each pvtItem In pvtField.PivotItems
If pvtItem.Value = filterCost Then
pvtField.CurrentPage = filterCost
Exit For
End If
Next pvtItem
<o:p></o:p>
End Sub
<o:p>