excel vba - How to remove all column fields in a Pivot Table ( Power Pivot)? -


everyone.

i using sub clearcolumns clear field in column area pivot table.

sub clearcolumns()  dim pt pivottable, pf pivotfield  set pt = activesheet.pivottables("tb1")      pt     each pf in .columnfields         pf.orientation = xlhidden     next pf end set pt = nothing  end sub 

but started using powerpivot, code doesnt work. think fields no longer pivotfield, cubefields. possible make same macro above, cubefields? tried different things, cant make work.

sub clearcolumnspp()  dim pt pivottable, pf cubefields dim strsource string dim strname string      set pt = activesheet.pivottables("tb1")  pt      each pf in .columnfields         strsource = pf.sourcename         strname = pf.name         pf(strsource, strname).orientation = xlhidden     next pf end      set pt = nothing      end sub 

thanks!!

you need check orientation of cubefield, , set hidden if column field:

sub foo()     dim pt pivottable     dim cf cubefield      set pt = activesheet.pivottables("tb1")     each cf in pt.cubefields         if cf.orientation = xlcolumnfield cf.orientation = xlhidden     next cf end sub 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -