数据透视表是使用数据连接的值创建的。对数据透视表中的值进行排序
我保存了一个宏来对值进行排序,但当我尝试在更新到另一个连接后运行它时,现在出现“下标超出范围”警告。我猜宏脚本正在使用我需要替换的静态范围,以便它可以运行到我可能具有的任何数据透视表结果。
但是我需要替换哪一行宏代码?
Sub SortLargestWarningsCount()
'Find the last used column in a Row
Dim LastCol As Integer
With ActiveSheet
LastCol = .Cells(6, .Columns.Count).End(xlToLeft).Column
End With
Worksheets("WARNINGS").Cells(6, LastCol).Activate
ActiveCell.Offset(1, 0).Activate
'Sort from Largest
ActiveSheet.PivotTables("WarningsPivotTable").PivotFields(_
"[Warnings].[Column5].[Column5]").AutoSort xlDescending, _
"[Measures].[Count of Column5]", ActiveSheet.PivotTables("WarningsPivotTable"). _
PivotColumnAxis.PivotLines(12), 1
End Sub
谢谢你的帮忙。