vba创建数据透视表的问题,这是excel版本的问题吗? [英] Issue with vba creating a pivot table, is this an excel version issue?

查看:346
本文介绍了vba创建数据透视表的问题,这是excel版本的问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速入门,获得了以下代码,该代码根据数据集合"Data"创建了数据透视表.我在创建它的PC上运行此程序,在运行Excel 2013的PC上没有问题,但是当我在Excel 2007或Excel 2010上运行它时,它在Range("A1")之后的行上抛出一个无效的过程调用或参数错误.选择

Quick one, got the following code which goes and creates a pivot table based on a data collection "Data". I run this on the PC that it was created on which runs Excel 2013 without an issue however when I run it on Excel 2007 or Excel 2010 it throws up an Invalid Procedure Call or Arguement error on the line after Range("A1").Select

这是Excel版本的错误,是因为它是用Excel 2013编写的,还是在2007或2010上使用的?

Is this an excel version error because written in Excel 2013 but used on 2007 or 2010?

    Sheets("Pivot").Select
    Range("A1").Select
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Data", Version:=xlPivotTableVersion15).CreatePivotTable TableDestination:= _
        "Pivot!R1C1", TableName:="PivotTable4", DefaultVersion:= _
        xlPivotTableVersion15
    Sheets("Pivot").Select
    Cells(1, 1).Select
    With ActiveSheet.PivotTables("PivotTable4").PivotFields("Date Only")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable4").PivotFields("Species")
        .Orientation = xlColumnField
        .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable4").AddDataField ActiveSheet.PivotTables( _
        "PivotTable4").PivotFields("Number"), "Sum of Number", xlSum

如果我认为这是一个版本问题,可能是因为人们使用了DefaultVersion:= xlPivotTableVersion14和12,有人知道哪个版本可以在Excel 2007或Excel 2010上运行吗?我假设如果我输入的是2007年的正确版本,它将与2010年和2013年等向下兼容...?

If it is a version issue which I think it might be as people have used DefaultVersion:=xlPivotTableVersion14 and 12 does anyone know which version would work on Excel 2007 or Excel 2010? I am assuming if I input correct version for 2007 it would be backwards compatible with 2010 and 2013 etc...?

预先加油 会

推荐答案

我认为这是Version:=xlPivotTableVersion15的问题,它特定于Excel2013.这是Excel 2010的帮助:

I think it's an issue with Version:=xlPivotTableVersion15, which is specific to Excel 2013. Here's the help from Excel 2010:

这是一个可选参数,在Excel 2010中,无论有没有,都可以正确创建数据透视表.

It is an optional argument and, in Excel 2010, the pivot table was created correctly with and without it.

这篇关于vba创建数据透视表的问题,这是excel版本的问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆