ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PivotTables Refresh not work (https://www.excelbanter.com/excel-programming/296818-pivottables-refresh-not-work.html)

No Name

PivotTables Refresh not work
 
Hi,
The following is the VBA code which is used to refresh
the PivotTable. But I found that it is always failed to
reflect newly added data (without any error) after the
first refresh.
Have anyone have any idea?
================================================== =========
Sub report_refresh()
Dim datarange As Variant

Sheets("report").Select
On Error Resume Next
ActiveSheet.PivotTables("Report1").PivotSelect "",
xlDataAndLabel
datarange = "Data!R1C1:R" & Trim(Str(Worksheets
("Container").Range("max_data").Value)) & "C6"
Sheets("Report").Select
ActiveSheet.PivotTableWizard SourceType:=xlDatabase,
SourceData:= _
datarange
ActiveSheet.PivotTables("Report1").RefreshTable

Application.CommandBars("PivotTable").Visible = False

End Sub


Toby Erkson

PivotTables Refresh not work
 
Why not use
ActiveWorkbook.RefreshAll

Toby Erkson
Oregon, USA

On Thu, 29 Apr 2004 21:03:28 -0700, wrote:

Hi,
The following is the VBA code which is used to refresh
the PivotTable. But I found that it is always failed to
reflect newly added data (without any error) after the
first refresh.
Have anyone have any idea?
================================================= ==========
Sub report_refresh()
Dim datarange As Variant

Sheets("report").Select
On Error Resume Next
ActiveSheet.PivotTables("Report1").PivotSelect "",
xlDataAndLabel
datarange = "Data!R1C1:R" & Trim(Str(Worksheets
("Container").Range("max_data").Value)) & "C6"
Sheets("Report").Select
ActiveSheet.PivotTableWizard SourceType:=xlDatabase,
SourceData:= _
datarange
ActiveSheet.PivotTables("Report1").RefreshTable

Application.CommandBars("PivotTable").Visible = False

End Sub




All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com