Custom Sort List For Pivot Table

wootenka

New Member
Joined
Sep 29, 2011
Messages
18
I am trying to use VBA to create a custom sort list for a pivot table based on the order of items on wkst SortLst. My Pivot table is is Sheet2(Company Wide). I am getting subscript out of range error.

Sub PivotTableSortUsingCustomLists3()
Dim rng As Range
Set rng = Worksheets("SortLst").Range("A:A")

Dim PvtTbl As PivotTable
Set PvtTbl = Worksheets("Sheet2").PivotTables("PivotTable1")

Application.AddCustomList rng
PvtTbl.SortUsingCustomLists = True
PvtTbl.PivotFields("Project Name").DataRange.Sort Order1:=xlAscending, Type:=xlSortLabels


End Sub
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Watch MrExcel Video

Forum statistics

Threads
1,099,115
Messages
5,466,765
Members
406,497
Latest member
Bryanlim

This Week's Hot Topics

Top