View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Where to input a SUB function?

Alt + F11 to open VBE.

CTRL + r to open project explorer.

Right-click on your workbook/project and InsertModule

Paste into that module.

Alt + q to return to the Excel window.

Good idea to save the workbook now.

ToolsMacroMacros.

Select the macro and Run

You could assign the macro to a button or keyboard short key combo.


Gord Dibben MS Excel MVP

On Wed, 24 Sep 2008 12:51:01 -0700, NightLord
wrote:

I found a site that shows some code for removing old entries in a PivotTable.
However, it does NOT say where to put the damn code. It's a SUB function.

Here is the code:
Sub DeleteMissingItems2002All()
'prevents unused items in non-OLAP PivotTables

Dim pt As PivotTable
Dim ws As Worksheet
Dim pc As PivotCache

'change the settings
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.PivotCache.MissingItemsLimit = xlMissingItemsNone
Next pt
Next ws

'refresh all the pivot caches
For Each pc In ActiveWorkbook.PivotCaches
On Error Resume Next
pc.Refresh
Next pc

End Sub


So, where do I input it??