hi,
i'm trying to use a cell reference to filter a pivot field in vba. it's almost working...
this is the code i'm using
ActiveSheet.PivotTables("PivotTable1").PivotFields("Trans Week"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Trans Week").PivotFilters. _
Add Type:=xlCaptionIsBetween, Value1:=CStr(Range("E3").Value), Value2:=CStr(Range("E2").Value)
currently cell E2 is "42" and E3 "38" so the code should be showing me column 38, 39, 40, 41 however when it runs it throws in column 4 too... cannot figure out why.. if i set the values in the code to 38 and 42, fine, but using the cell ref... i don't know
any help would be much appreciated.
Thanks!
i'm trying to use a cell reference to filter a pivot field in vba. it's almost working...
this is the code i'm using
ActiveSheet.PivotTables("PivotTable1").PivotFields("Trans Week"). _
ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Trans Week").PivotFilters. _
Add Type:=xlCaptionIsBetween, Value1:=CStr(Range("E3").Value), Value2:=CStr(Range("E2").Value)
currently cell E2 is "42" and E3 "38" so the code should be showing me column 38, 39, 40, 41 however when it runs it throws in column 4 too... cannot figure out why.. if i set the values in the code to 38 and 42, fine, but using the cell ref... i don't know
any help would be much appreciated.
Thanks!