Replace Contents of Destination Cells

G

Guest

Hi all,
I'm using the following code to update data for a pivot table. Sometimes i
get the following message: "Do you want to replace the contents of the
destination cells in [worksheet name]?"

I'm using the same code in another workbook, however, i never get that
message. What makes this message appear in one workbook and not the other?
The only difference is that the workbook that displays the message contains
only 1 pivot table, while the other workbook contains 2 pivot tables. Could
this be the reason why? I can't see how. Your help will be greatly
appreciated.
I'm using Excel 2003

The code is:


Sub Refresh()

' Unprotect the sheet
ActiveSheet.Unprotect

' Clear old items from the list and Refresh data

Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
pt.PivotCache.MissingItemsLimit = xlMissingItemsNone
pt.PivotCache.Refresh
Next pt

Range("E2").Select

' protect sheet

ActiveSheet.Protect DrawingObjects:=True, contents:=True,
Scenarios:=True _
, AllowFiltering:=True


End Sub
 
D

Dave Peterson

Untested...

Try adding:

Application.displayalerts = false
'the line that causes the warning
application.displayalerts = true

".displayalerts = false" can stop lots of warnings, but not all.
Hi all,
I'm using the following code to update data for a pivot table. Sometimes i
get the following message: "Do you want to replace the contents of the
destination cells in [worksheet name]?"

I'm using the same code in another workbook, however, i never get that
message. What makes this message appear in one workbook and not the other?
The only difference is that the workbook that displays the message contains
only 1 pivot table, while the other workbook contains 2 pivot tables. Could
this be the reason why? I can't see how. Your help will be greatly
appreciated.
I'm using Excel 2003

The code is:

Sub Refresh()

' Unprotect the sheet
ActiveSheet.Unprotect

' Clear old items from the list and Refresh data

Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
pt.PivotCache.MissingItemsLimit = xlMissingItemsNone
pt.PivotCache.Refresh
Next pt

Range("E2").Select

' protect sheet

ActiveSheet.Protect DrawingObjects:=True, contents:=True,
Scenarios:=True _
, AllowFiltering:=True


End Sub
 
G

Guest

It worked, thanks Dave.


Dave Peterson said:
Untested...

Try adding:

Application.displayalerts = false
'the line that causes the warning
application.displayalerts = true

".displayalerts = false" can stop lots of warnings, but not all.
Hi all,
I'm using the following code to update data for a pivot table. Sometimes i
get the following message: "Do you want to replace the contents of the
destination cells in [worksheet name]?"

I'm using the same code in another workbook, however, i never get that
message. What makes this message appear in one workbook and not the other?
The only difference is that the workbook that displays the message contains
only 1 pivot table, while the other workbook contains 2 pivot tables. Could
this be the reason why? I can't see how. Your help will be greatly
appreciated.
I'm using Excel 2003

The code is:

Sub Refresh()

' Unprotect the sheet
ActiveSheet.Unprotect

' Clear old items from the list and Refresh data

Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
pt.PivotCache.MissingItemsLimit = xlMissingItemsNone
pt.PivotCache.Refresh
Next pt

Range("E2").Select

' protect sheet

ActiveSheet.Protect DrawingObjects:=True, contents:=True,
Scenarios:=True _
, AllowFiltering:=True


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top