Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@yamamon123

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

More than 3 years have passed since last update.

ピボットテーブルをマクロで扱う際は、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では下記エラーを出力して停止します。
「プロシージャの呼び出し、または引数が不正です。」

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?