ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA AutoFilter of a PivotTable (https://www.excelbanter.com/excel-discussion-misc-queries/237663-vba-autofilter-pivottable.html)

jxbeeman

VBA AutoFilter of a PivotTable
 
Hello,
I'm having trouble with my Macro that Filters a Pivottable. What i'm trying
to do is sort the pivot table on the totals so i can highlight them and bold
them. If there is an better way to do this i would appreciate it. Below is
the code that was generated from recording the macro, problem is it dosen't
work when you try to replay it.

Selection.AutoFilter
ActiveSheet.Range("$A$4:$L$2150").AutoFilter Field:=13, Criteria1:="=1", _
Operator:=xlOr, Criteria2:="="

Thanks,
Josh

broro183[_9_]

VBA AutoFilter of a PivotTable
 

hi Josh,

Rather than using an autofilter would it work if you recorded a macro
of rightclicking on a cell in the "row fields" section of the pivot
table, choosing Field Settings - Advanced - Sort... which should
generate something like the below code?

Code:
--------------------
ActiveSheet.PivotTables("PivotTable1").PivotFields ("gf").AutoSort xlDescending, "Sum of dgf"
--------------------


hth
Rob


--
broro183

Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: http://www.thecodecage.com/forumz/member.php?userid=333
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=118446



All times are GMT +1. The time now is 08:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com