事先设定好范围 这个范围的列和行通过参数来判断 Set DataRng = Range("A1:D" & zuidazhi) Set ptcache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:=DataRng) Sheets.Add Sheets("Sheet1").Select Set pt = ptcache.CreatePivotTable(tabledestination:=Sheets("Sheet1").Range("b1"), TableName:="pivottable1") With ActiveSheet.PivotTables("pivottable1").PivotFields("采样时间") .Orientation = xlRowField .Position = 1 End With
- 相关评论
- 我要评论
-