Into my workbook I've the db of inventory, in another sheet I've one pvt and in the filter field I put the filed Card. Now I want create one sheet for each Card usually I use this code for this operation:Sub cmdg2b2(control As IRibbonControl)  'genera una sheets per ogni cardApplication.ScreenUpdating = FalseApplication.Calculation = xlCalculationManual    Sheets(pivot).Select    ActiveSheet.Unprotect    ActiveSheet.PivotTables(Pvt_Pck).ShowPages PageField:=Card    Sheets(pivot).Protect DrawingObjects:=True, Contents:=True, Scenarios:=True    Sheets(pivot).EnableSelection = xlNoSelectionApplication.ScreenUpdating = TrueApplication.Calculation = xlCalculationAutomaticEnd SubThis function always runs right, but this year the sheets are much (175) and my code stopped for exceeded memory. I think to hide half off the total sheets, if I hide the sheets manually with pvt filer the operation run in a couple of minutes, if I use this code I need 9 minutes.Can somebody help me to improve the performance my code?Function ShowSheets(ByVal conta As String)  'card serves to define whether to show the first half of the sheets or the secondApplication.ScreenUpdating = FalseApplication.Calculation = xlCalculationManualDim tsheet As IntegerDim tstart As Date, tend As Date, tteempo As Datetstart = Now()    ActiveSheet.PivotTables(Pvt_Pck).PivotFields(Card).CurrentPage = (All)    With ActiveSheet.PivotTables(Pvt_Pck).PivotFields(Card)    tsheet = Int(.PivotItems.Count / 2)    Select Case conta    Case A        For i = 1 To tsheet            .PivotItems(i).Visible = False        Next i    Case B        For i = tsheet + 1 To .PivotItems.Count - 1            .PivotItems(i).Visible = False        Next i    End Select    End With    Range(A4).SelectApplication.ScreenUpdating = TrueApplication.Calculation = xlCalculationAutomatictend = Now()ttempo = tend - tstartDebug.Print ttempoEnd Function
Show one sheet for each field in pivot filter field
performance;vba;excel