|
发表于 2015-5-28 09:11
|
显示全部楼层
本楼为最佳答案
Sub test7()
On Error Resume Next
Application.AddCustomList Array("M", "L", "XL", "2XL", "3XL", "4XL") '用了数组,就可以不用辅助区
On Error GoTo 0
Sheets.Add after:=Sheets(Sheets.Count)
With ActiveSheet.PivotTableWizard(xlDatabase, Sheets(1).[a1].CurrentRegion)
.PivotFields("货号").Orientation = xlRowField
.PivotFields("尺寸").Orientation = xlColumnField
.PivotFields("数量").Orientation = xlDataField
End With
Dim A
A = Range("a1").CurrentRegion.Offset(1, 0)
Cells.Clear
Range("a1").Resize(UBound(A), UBound(A, 2)).Value = A
Range("a1").CurrentRegion.Borders.LineStyle = 1
ActiveWindow.DisplayGridlines = False
Application.DeleteCustomList Application.CustomListCount '删除最后一条(也就是本过程添加的)自定义序列
End Sub
说明:
绿色部分执行后,excel中新增加一条自定义序列。
执行其它操作,...
蓝色部分执行后,由绿色部分增加的自定义序列便删除了。也就是说,没有'后遗症'。
|
|