0

I have pivot charts in my workbook. Somehow, when I run my macro, the pivot tables are not showing. When I run the macro again, the pivot charts are showing. How come?

Also sometimes, but not always, the next line gives an error (in the part Resfresh output): Selection.NumberFormat = "0%"

I have tried code to unhide the pivot charts with .Visible = True. It still doesn't show the pivot tables

Sub CopyOrders()

' Unhide all Sheets
For Each ws In ActiveWorkbook.Worksheets
    ws.Visible = xlSheetVisible
    If ws.AutoFilterMode Or ws.FilterMode Then
        ws.ShowAllData
    End If
    ws.Columns.EntireColumn.Hidden = False
    ws.Rows.EntireRow.Hidden = False
Next ws

ActiveWorkbook.SlicerCaches("Slicer_Site_Peros_Number___Name"). _
    ClearManualFilter

' Other code is showing here to calculate and form the tables my pivotcharts are coming from


' Refresh Output
Sheets("Output Frames").Select
ActiveSheet.PivotTables("PivotTableArticles").PivotCache.Refresh
Sheets("Output Frames").PivotTables("PivotTableArticles").DataBodyRange.NumberFormat = "dd/mm/yyyy"
Sheets("Output Frames").PivotTables("PivotTableSoldPerSite").PivotSelect "Percentage", _
    xlDataAndLabel, True
Selection.NumberFormat = "0%"
Columns("A:R").EntireColumn.AutoFit
Range("A2:P4").Font.Size = 30
Range("A6:P8").Font.Size = 20
Range("A42:P44").Font.Size = 20
Range("A1").Select

' Hide Data
Sheets("Output Frames").Columns("R:XFD").EntireColumn.Hidden = True
Sheets("Output Frames").Columns("H").EntireColumn.Hidden = True
Sheets("Output Frames").Columns("N").EntireColumn.Hidden = True
Sheets("Sales").Visible = xlSheetHidden
Sheets("Orders vs Sales").Visible = xlSheetHidden
Sheets("Sitenumbers").Visible = xlSheetHidden
Sheets("PivotTables").Visible = xlSheetHidden

End Sub

Can someone tell why the pivot tables aren't showing the first time en how to fix this?

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Aletta
  • 1
  • 1
    *"Somehow, when I run my macro, the pivot tables are not showing. When I run the macro again, the pivot charts are showing. How come?"* - Pivot tables or pivot charts? The two are not the same. I'm having a hard time understanding your problem. – dwirony Jan 23 '19 at 16:25
  • Sorry, It is about the pivot charts. The pivot tables are working fine. – Aletta Jan 28 '19 at 08:29

0 Answers0