The secret to refreshing a pivot table with new data is not to address the
table itself, but merely re-define the source data that the PT uses. Use a
named range for the data such as "Database". Go to your PT and use the
Wizard to set the data range to Date Detail!Database. This sets your data
range to a named range. Now all you need to do is to re-define the named
range when new data is imported.
> 'Get a reference to the source data table
> With ThisWorkbook.Worksheets("Date Detail")
> Set rngSource = .Range(.Cells(1, 1), .Cells(LastRow, LastCol))
'next line will re-define the named range
.Names("Database").RefersTo = "=" & rngSource.Address(1, 1, xlA1, True)
> End With
'next line will refresh PTs
ThisWorkbook.RefreshAll
End Sub
Since you have 6 columns of data and 2 PTs that only refer to half of the
data columns you may want to use 2 named ranges, one for the first 3 columns
and a different name for the last 3 columns. You would then use the above
procedure to re-define 2 named ranges.
> 'Get a reference to the source data table
> With ThisWorkbook.Worksheets("Date Detail")
Set rngSource = .Range(.Cells(1, 1), .Cells(LastRow, LastCol - 3))
'next line will re-define the named range
.Names("Database1").RefersTo = "=" & rngSource.Address(1, 1, xlA1, True)
Set rngSource = .Range(.Cells(4, 1), .Cells(LastRow, LastCol))
.Names("Database2").RefersTo = "=" & rngSource.Address(1, 1, xlA1, True)
> End With
'next line will refresh PTs
ThisWorkbook.RefreshAll
End Sub
Hope this helps,
Mike F
> Hi!
>
[quoted text clipped - 82 lines]
>
> Tammy