谢谢!你录的这个有用,但我录得怎么就没用啊?看我录的代码(没改过的),有很大区别 Sub Macro3() ' ' Macro3 Macro ' wwyp 记录的宏 2007-6-21 ' Columns("B:C").Select ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ "Sheet1!C2:C3").CreatePivotTable TableDestination:="[help.xls]Sheet1!R4C6", _ TableName:="数据透视表3", DefaultVersion:=xlPivotTableVersion10 ActiveWorkbook.ShowPivotTableFieldList = True With ActiveSheet.PivotTables("数据透视表3").PivotFields("cn") .Orientation = xlRowField .Position = 1 End With With ActiveSheet.PivotTables("数据透视表3").PivotFields("type") .Orientation = xlColumnField .Position = 1 End With ActiveSheet.PivotTables("数据透视表3").AddDataField ActiveSheet.PivotTables("数据透视表3" _ ).PivotFields("type"), "计数项:type", xlCount End Sub |