excel pivot table最大数据量

时间:2016-11-24 13:14:24

标签: excel excel-vba pivot-table vba

我编写的用于选择范围内所有活动单元格的VBA代码可以很好地处理少量数据。但是当我有80.000行时,我收到了创建我的数据透视表的错误。 我使用的数据是计算几个温度的平均值。除了平均值,我需要计算,stdev,var,amount,min和max

我要创建的数据透视表: 1

当我选择超过80.000时,它会在上下文中创建错误代码"未定义的表达式"

vba代码: 2

所以我的问题是,是否有最大数量来创建数据透视表? 如果有的话,有没有办法解决这个问题?

Sub Draaitabel()
Sheets("Draaitabellen").Select
Cells.Select
Selection.ClearContents
Dim newRange As Range
Sheets("Doorvoeren").Select
Range("B3:D3").Select
Range(Selection, Selection.End(xlDown)).Select
Set newRange = Selection

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        newRange, Version:=xlPivotTableVersion14).CreatePivotTable _
        TableDestination:="Draaitabellen!R3C1", TableName:="Draaitabel1", _
        DefaultVersion:=xlPivotTableVersion14
    Sheets("Draaitabellen").Select
    Cells(3, 1).Select
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Steekproef")
        .Orientation = xlRowField
        .Position = 1
    End With
    ActiveSheet.PivotTables("Draaitabel1").AddDataField ActiveSheet.PivotTables( _
        "Draaitabel1").PivotFields("Temperatuur"), "Som van Temperatuur", xlSum
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Som van Temperatuur")
        .Caption = "Aantal van Temperatuur"
        .Function = xlCount
    End With
    ActiveSheet.PivotTables("Draaitabel1").AddDataField ActiveSheet.PivotTables( _
        "Draaitabel1").PivotFields("Temperatuur"), "Som van Temperatuur", xlSum
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Som van Temperatuur")
        .Caption = "Gemiddelde van Temperatuur"
        .Function = xlAverage
    End With
    ActiveSheet.PivotTables("Draaitabel1").AddDataField ActiveSheet.PivotTables( _
        "Draaitabel1").PivotFields("Temperatuur"), "Som van Temperatuur", xlSum
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Som van Temperatuur")
        .Caption = "Stdev van Temperatuur"
        .Function = xlStDev
    End With
    ActiveSheet.PivotTables("Draaitabel1").AddDataField ActiveSheet.PivotTables( _
        "Draaitabel1").PivotFields("Temperatuur"), "Som van Temperatuur", xlSum
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Som van Temperatuur")
        .Caption = "Var van Temperatuur"
        .Function = xlVar
    End With
    ActiveSheet.PivotTables("Draaitabel1").AddDataField ActiveSheet.PivotTables( _
        "Draaitabel1").PivotFields("Temperatuur"), "Som van Temperatuur", xlSum
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Som van Temperatuur")
        .Caption = "Min van Temperatuur"
        .Function = xlMin
    End With
    ActiveSheet.PivotTables("Draaitabel1").AddDataField ActiveSheet.PivotTables( _
        "Draaitabel1").PivotFields("Temperatuur"), "Som van Temperatuur", xlSum
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Som van Temperatuur")
        .Caption = "Max van Temperatuur"
        .Function = xlMax
    End With
    ActiveSheet.PivotTables("Draaitabel1").AddDataField ActiveSheet.PivotTables( _
        "Draaitabel1").PivotFields("Tijd"), "Som van Tijd", xlSum
    With ActiveSheet.PivotTables("Draaitabel1").PivotFields("Som van Tijd")
        .Caption = "Min van Tijd"
        .Function = xlMin
    End With
End Sub

0 个答案:

没有答案