关于VBA编程 操作excel表的问题
这是我写的VBA宏,不知道怎么错了,请各位大虾看下subtest()DimmysheetAsWorksheetForEachmysheetInWorksheetsWith...
这是我写的VBA宏,不知道怎么错了,请各位大虾看下
sub test()
Dim mysheet As Worksheet
For Each mysheet In Worksheets
With mysheet.Columns("A:G").Select
Range("G1").Activate
ActiveWorkbook.PivotCaches.Create (SourceType:=xlDatabase, SourceData:= _
"my sheet!R1C1:R65536C7", Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="my sheet!R9C10", tablename:= _
"数据透视表1", DefaultVersion:=xlPivotTableVersion10
Sheets("my sheet").Select
Cells(9, 10).Select
ActiveSheet.PivotTables("数据透视表1").AddDataField ActiveSheet.PivotTables("数据透视表1" _
).PivotFields("包括dns解析整体时间"), "计数项:包括dns解析整体时 间", xlCount
With ActiveSheet.PivotTables("数据透视表1").PivotFields("测试ip")
.Orientation = xlRowField
.Position = 1
End With
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
Range("K20").Select
ActiveSheet.PivotTables("数据透视表1").PivotFields("计数项:包括dns解析 整体时间").Function = _
xlAverage
End With
Next mysheet
End Sub 展开
sub test()
Dim mysheet As Worksheet
For Each mysheet In Worksheets
With mysheet.Columns("A:G").Select
Range("G1").Activate
ActiveWorkbook.PivotCaches.Create (SourceType:=xlDatabase, SourceData:= _
"my sheet!R1C1:R65536C7", Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="my sheet!R9C10", tablename:= _
"数据透视表1", DefaultVersion:=xlPivotTableVersion10
Sheets("my sheet").Select
Cells(9, 10).Select
ActiveSheet.PivotTables("数据透视表1").AddDataField ActiveSheet.PivotTables("数据透视表1" _
).PivotFields("包括dns解析整体时间"), "计数项:包括dns解析整体时 间", xlCount
With ActiveSheet.PivotTables("数据透视表1").PivotFields("测试ip")
.Orientation = xlRowField
.Position = 1
End With
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
Range("K20").Select
ActiveSheet.PivotTables("数据透视表1").PivotFields("计数项:包括dns解析 整体时间").Function = _
xlAverage
End With
Next mysheet
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询