• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

need help for VBA Code to use for formatting pivot table

Rodney Coello

New Member
i'm trying to set up a vba code that will format any pivot table to "pivotstylemedium2"
what am i doing wrong? can you advice? thanks,

Option Explicit

Sub Macro1()
'
' Macro1 Macro
'

'

Dim df As PivotField
' Ignore errors
On Error Resume Next

'
For Each df In ActiveSheet.PivotTables(1).DataFields
ActiveSheet.PivotTables("PivotTable").TableStyle2 = "PivotStyleMedium2"

Next df


End Sub
 
Hi and welcome to the forum ;)

Maybe something like:
Code:
Sub SetPTStyle()

    Dim PT As PivotTable
   
    For Each PT In ActiveSheet.PivotTables
        PT.TableStyle2 = "PivotStyleMedium2"
    Next PT

End Sub
 
Back
Top