メインコンテンツへスキップ

ピボットテーブルの複数のフィールド設定を変更するにはどうすればよいですか?

ワークシートにピボットテーブルを作成するとき、フィールドをにドラッグした後 価値観 のリスト ピボットテーブルフィールドリスト、あなたはすべて同じになるかもしれません ワンランク上の 次のスクリーンショットのように機能します。 しかし今、あなたは 合計 置き換える機能の ワンランク上の 一度に機能の、Excelで一度に複数のピボットテーブルフィールドの計算を変更するにはどうすればよいですか?

doc-change-field-setting-1

ピボットテーブルのフィールド設定をXNUMXつずつ手動で変更します

VBAコードを使用してピボットテーブルの複数のフィールド設定を変更する


矢印青い右バブル ピボットテーブルのフィールド設定をXNUMXつずつ手動で変更します

Excelでは、関数をXNUMXつずつ変更することで、フィールド設定の計算を変更できます。 値フィールド設定 ダイアログ、次のようにしてください:

1。 ピボットテーブルの集計機能を変更する[値]領域のフィールドを選択し、右クリックして選択します 値フィールド設定、スクリーンショットを参照してください:

doc-change-field-setting-1

2。 その後、 値フィールド設定 ダイアログボックスで、使用する計算の種類をXNUMXつ選択します。 値を要約する タブ、スクリーンショットを参照してください:

doc-change-field-setting-1

3。 そして、 OK このダイアログを閉じると、Count関数がSum関数に変更されていることがわかります。スクリーンショットを参照してください。

doc-change-field-setting-1

4。 上記の手順を繰り返して、他のフィールドの計算設定をXNUMXつずつ変更します。

注: フィールドセルをXNUMXつ右クリックして、フィールド設定を変更することもできます。 値を要約する コンテキストメニューから必要な計算をXNUMXつ選択します。

doc-change-field-setting-1


矢印青い右バブル VBAコードを使用してピボットテーブルの複数のフィールド設定を変更する

上記の方法は、変更する必要のあるフィールド計算がたくさんある場合、時間と手間がかかります。ここでは、複数のフィールド設定を同時に変更するコードを紹介します。

1。 ピボットテーブルの任意のセルをクリックします。

2。 を押し続けます Alt + F11 キー、そしてそれは開きます Microsoft Visual Basic forApplicationsウィンドウ.

3に設定します。 OK をクリックします。 インセット > モジュール、次のコードをに貼り付けます モジュールウィンドウ.

VBAコード:ピボットテーブルの複数のフィールド設定を変更します

Public Sub SetDataFieldsToSum()
'Update 20141127
Dim xPF As PivotField
Dim WorkRng As Range
Set WorkRng = Application.Selection
With WorkRng.PivotTable
   .ManualUpdate = True
   For Each xPF In .DataFields
      With xPF
         .Function = xlSum
         .NumberFormat = "#,##0"
      End With
   Next
   .ManualUpdate = False
End With
End Sub

4。 次に、 F5 このコードを実行するためのキーを押すと、選択したピボットテーブルのすべてのフィールド設定が一度に必要な計算に変換されます。スクリーンショットを参照してください。

doc-change-field-setting-1
-1
doc-change-field-setting-6

Note:上記のコードでは、Sum関数を、必要に応じて、平均、最大、最小などの他の計算に変更できます。 これらのスクリプトで合計を変更する必要があります。 Public Sub SetDataFieldsToSum() & .関数 = xlSum 他の機能に。

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (29)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Brilliant, thanks, this worked perfectly and save much time
This comment was minimized by the moderator on the site
Muchas gracias por el aporte
This comment was minimized by the moderator on the site
Hi!

I'm wondering how to use the code for Count Numbers instead of count, I've tried changing the code to Count Numbers and CountNumbers but netiher works..

Help is appreciated :)
This comment was minimized by the moderator on the site
Hello, Sara,
Sorry for that your Count Numbers field can't be changed in the code, so, you need to change the field one by one with the first method in this article.
Thank you!
This comment was minimized by the moderator on the site
Thank you so much, this VBA code works amazing. 
This comment was minimized by the moderator on the site
I got the error" Unable to get the PivotTable property of the range class". Do you know hoe can I fix this?
This comment was minimized by the moderator on the site
I got this error, "Unable to get the Pivot Table property of the Range class". Do you know how I can fix this?
This comment was minimized by the moderator on the site
Thank you so much!!! That is sooo helpful and brilliant! Saved me soooo much time
This comment was minimized by the moderator on the site
Thank you so much for the VBA code, I LOVE it!
This comment was minimized by the moderator on the site
Thank you. The code worked beautifully and saved me a lot of wasted time and energy!
This comment was minimized by the moderator on the site
I've used the VBA solution with great success in the past, but it doesn't work with the data model. Do you know if there is a solution for that?
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations