Log in

View Full Version : EXPORT THEN REFRESH AUTOMATICALLY THE PIVOT TABLE



jffryjsphbyn
07-24-2013, 06:55 AM
Hello there!

Can you help me in exporting a file when exported, the pinot table in the summary sheet will automatically refresh to have the details.

Here's the partial code.



Sub Export()

Dim Keyword As String

Keyword = UCase$(Worksheets("INSTRUCTIONS").Range("O24").Value)

Application.DisplayAlerts = False

Select Case Keyword
Case "RNAM"
Sheets(Array("CLASSIFIED-RNAM", "SUMMARY-RNAM")).Copy
With ActiveWorkbook
.Title = "Classified"
.Close True
End With

Case "RECA-RWCE"
Sheets(Array("CLASSIFIED-RECA-RWCE", "SUMMARY-RECA-RWCE")).Copy
With ActiveWorkbook
.Title = "Classified"
.Close True
End With

Case "RRR"
Sheets(Array("CLASSIFIED-RRR", "SUMMARY-RRR")).Copy
With ActiveWorkbook
.Title = "Classified"
.Close True
End With

Case "RASO-RNEA"
Sheets(Array("CLASSIFIED-RASO-RNEA", "SUMMARY-RASO-RNEA")).Copy
With ActiveWorkbook
.Title = "Classified"
.Close True
End With

Case "SWEDEN"
Sheets(Array("CLASSIFIED-SWEDEN", "SUMMARY-SWEDEN")).Copy
With ActiveWorkbook
.Title = "Classified"
.Close True
End With

Case "RLAM"
Sheets(Array("CLASSIFIED-RLAM", "SUMMARY-RLAM")).Copy
With ActiveWorkbook
.Title = "Classified"
.Close True
End With

End Select
Application.DisplayAlerts = True

End Sub


The only thing missing in the code is the refreshing of pivot tables during exports.

Thanks!

Excel Fox
07-24-2013, 07:32 AM
You can use this code to refresh all pivot tables in a workbook. Surely, you can make the modification as per your need.


ActiveWorkbook.RefreshAll
OR

Workbooks(1).RefreshAll
OR

Workbooks("Name Of Workbook.xls").RefreshAll