Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have two Pivot Reports and two data sheets in my template workbook. New
data sheets are added by a third party program. When the book is opened, excel start up macros replace the data sheets with the new data and refresh the pivots. But sometimes, the drop lists are not in sorted order - even though the data rows are sorted in the data sheets. How can the droplists be made to be sorted ? -- Jeff |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is some code that refreshes the lists...
Sub DeleteOldItemsWB() 'gets rid of unused items in PivotTable ' based on MSKB (202232) Dim ws As Worksheet Dim pt As PivotTable Dim pf As PivotField Dim pi As PivotItem On Error Resume Next For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.RefreshTable For Each pf In pt.VisibleFields If pf.Name < "Data" Then For Each pi In pf.PivotItems If pi.RecordCount = 0 And _ Not pi.IsCalculated Then pi.Delete End If Next End If Next Next Next End Sub Sub DeleteMissingItems2002All() ' prevents unused items in PivotTable ' ' in Excel 2002 and later versions ' If unused items already exist, ' run this macro then refresh the table Dim pt As PivotTable Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.PivotCache.MissingItemsLimit = xlMissingItemsNone pt.PivotCache.Refresh Next pt Next ws End Sub Here is a good link to get more info... http://www.contextures.com/tiptech.html -- HTH... Jim Thomlinson "Jeff" wrote: I have two Pivot Reports and two data sheets in my template workbook. New data sheets are added by a third party program. When the book is opened, excel start up macros replace the data sheets with the new data and refresh the pivots. But sometimes, the drop lists are not in sorted order - even though the data rows are sorted in the data sheets. How can the droplists be made to be sorted ? -- Jeff |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks
-- Jeff "Jim Thomlinson" wrote: Here is some code that refreshes the lists... Sub DeleteOldItemsWB() 'gets rid of unused items in PivotTable ' based on MSKB (202232) Dim ws As Worksheet Dim pt As PivotTable Dim pf As PivotField Dim pi As PivotItem On Error Resume Next For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.RefreshTable For Each pf In pt.VisibleFields If pf.Name < "Data" Then For Each pi In pf.PivotItems If pi.RecordCount = 0 And _ Not pi.IsCalculated Then pi.Delete End If Next End If Next Next Next End Sub Sub DeleteMissingItems2002All() ' prevents unused items in PivotTable ' ' in Excel 2002 and later versions ' If unused items already exist, ' run this macro then refresh the table Dim pt As PivotTable Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.PivotCache.MissingItemsLimit = xlMissingItemsNone pt.PivotCache.Refresh Next pt Next ws End Sub Here is a good link to get more info... http://www.contextures.com/tiptech.html -- HTH... Jim Thomlinson "Jeff" wrote: I have two Pivot Reports and two data sheets in my template workbook. New data sheets are added by a third party program. When the book is opened, excel start up macros replace the data sheets with the new data and refresh the pivots. But sometimes, the drop lists are not in sorted order - even though the data rows are sorted in the data sheets. How can the droplists be made to be sorted ? -- Jeff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot Table and Pivot Table dates are not in correct order | Charts and Charting in Excel | |||
pivot table - drop down filter box has 10% of items out of order | Excel Discussion (Misc queries) | |||
Pivot Table - Column Drop Down Lists... | Excel Discussion (Misc queries) | |||
Pivot tables and drop-down lists | New Users to Excel | |||
Order of Pivot Drop-Down (Page Field) | Excel Discussion (Misc queries) |