LoginSignup
2
1

More than 5 years have passed since last update.

【VBA】ピボットテーブルについて

Last updated at Posted at 2017-08-29

ピボットテーブルをマクロで扱う際は、Excel2010とそれ以降で構文が異なります。
以下に例を記載します。

■Excel2010で作成

        'ピボットテーブル作成
        ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
            wks_ARRAY(i).Cells(1, 1).CurrentRegion, Version:=xlPivotTableVersion14).CreatePivotTable _
           TableDestination:=Cells(3, 1), TableName:=str_PIVOT_TABLE_NAME(i), DefaultVersion:=xlPivotTableVersion14

■Excel2016で作成

        ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
            wks_ARRAY(i).Cells(1, 1).CurrentRegion, Version:=6).CreatePivotTable TableDestination:= _
            Cells(3, 1), TableName:=str_PIVOT_TABLE_NAME(i), DefaultVersion:=6

Excel2016でマクロを作成している場合、
【Version:=xlPivotTableVersion14】
を指定しないとExcel2010では下記エラーを出力して停止します。
「プロシージャの呼び出し、または引数が不正です。」

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1