I have some code that creates a pivot table the only problem is that two small windows keep poping up on the screen, I thought I could use the Application.DisplayAlerts = False at the begining of the script to disable those windows?
The windows that pop up are Pivot Table and pivot table field list.
Here is my code.
Any Idea what I did wrong?
Thanks as always ,Mike
Sub Pivot()
Stop
Dim Ws As Worksheet, strSource As String
Dim PT As PivotTable, pc As PivotCache, pf As PivotField
Application.DisplayAlerts = False
For Each Ws In ActiveWorkbook.Worksheets
strSource = Ws.Name & "!R1C1:R5000C4"
ActiveWorkbook.Worksheets.Add 'new worksheet becomes the active sheet
'ActiveSheet.Name = "Info"
Set pc = ActiveWorkbook.PivotCaches.Add(xlDatabase, strSource)
Set PT = pc.CreatePivotTable(Range("A1")) 'pivot table at A1 on new sheet
Set pf = PT.PivotFields("Order Number")
PT.AddDataField pf, "Count of Order Number", xlCount
PT.AddFields RowFields:="Name"
Next Ws
Application.DisplayAlerts = True
End Sub
Bookmarks