View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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