下次宏运行时更改PivotStyle

时间:2016-02-03 05:33:17

标签: excel vba excel-vba pivot-table

我想在下次运行仪表板时更改枢轴数,请为同一编码建议:

Set rng = ws.Range("A1:" & Split(Cells(, lastcol).Address, "$")(1) & lastrow)
srcdata = rng.Address(ReferenceStyle:=xlR1C1)
Set pvtch = ActiveWorkbook.PivotCaches.Create(xlDatabase, srcdata)
Set pvtbl = pvtch.CreatePivotTable(tableDestination:=ptws.Range("A3"), tablename:="PivotTable1")
pvtbl.PivotFields("TAT Status").Orientation = xlRowField
pvtbl.PivotFields("RequestType").Orientation = xlRowField
pvtbl.PivotFields("Case Owner").Orientation = xlColumnField
pvtbl.AddDataField pvtbl.PivotFields("Reference no"), "Count_Ticket_ID", xlCount
ptws.Range("A4").Value = "Ticket Type with TAT"
pvtbl.TableStyle2 = "PivotStyleDark1" 'Here I want to change the style every next time when pivot table create.

0 个答案:

没有答案