AlwaysNeedExcelHelp
New Member
- Joined
- Sep 24, 2019
- Messages
- 6
Hello,
I am looking to use inputs in my excel to alter a pivot table to show only the values between the min and the max inputs. I have the below code but the highlight part is where I fail. How can I reference the values? It produces a "Unable to get the PivotTables property of the Worksheet class" error.
Thank you,
Sub EditRange()
Dim a
Dim b
a = Range("b3").Value
b = Range("c3").Value
ActiveSheet.PivotTables("RangePivot").PivotFields("Office").ClearAllFilters
ActiveSheet.PivotTables("RangePivot").PivotFields("Office").PivotFilters.Add2 _
Type:=xlValueIsBetween, DataField:=ActiveSheet.PivotTables("PivotTable1"). _
PivotFields("Sum of Net Revenues"), Value1:=a, Value2:=b
End Sub
I am looking to use inputs in my excel to alter a pivot table to show only the values between the min and the max inputs. I have the below code but the highlight part is where I fail. How can I reference the values? It produces a "Unable to get the PivotTables property of the Worksheet class" error.
Thank you,
Sub EditRange()
Dim a
Dim b
a = Range("b3").Value
b = Range("c3").Value
ActiveSheet.PivotTables("RangePivot").PivotFields("Office").ClearAllFilters
ActiveSheet.PivotTables("RangePivot").PivotFields("Office").PivotFilters.Add2 _
Type:=xlValueIsBetween, DataField:=ActiveSheet.PivotTables("PivotTable1"). _
PivotFields("Sum of Net Revenues"), Value1:=a, Value2:=b
End Sub