これを行うことができますが、ピボットテーブルの数字の「プレースホルダ」値をテキストで一時的に上書きする必要があります。これを有効にするには、ピボットテーブルに対してEnableDataValueEditing = Trueを設定する必要があります。リフレッシュ時には、数値のプレースホルダ値を検索し、テキストで置き換えます。畳んだ、はい。回避策、はい。しかしそれはトリックです。ピボットテーブルが次にリフレッシュされるまでこれが「スティック」するだけであるため、このコードはすべてのリフレッシュ時にトリガされる必要があります。
私が自分のプロジェクトでこれを行うために使用するコードは次のとおりです。標準コードモジュールでこれを入れて:
Function Pivots_TextInValuesArea(pt As PivotTable, rngNumeric As Range, rngText As Range, Optional varNoMatch As Variant)
Dim cell As Range
Dim varNumeric As Variant
Dim varText As Variant
Dim varResult As Variant
Dim bScreenUpdating As Boolean
Dim bEnableEvents As Boolean
Dim lngCalculation As Long
On Error GoTo errHandler
With Application
bScreenUpdating = .ScreenUpdating
bEnableEvents = .EnableEvents
lngCalculation = .Calculation
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
varNumeric = rngNumeric
varText = rngText
pt.EnableDataValueEditing = True
'Setting this to TRUE allow users or this code to temporarily overwrite PivotTable cells in the VALUES area.
'Note that this only 'sticks' until the next time the PivotTable is refreshed, so this code needs to be
' triggerred on every refresh
For Each cell In pt.DataBodyRange.Cells
With cell
varResult = Application.Index(varText, Application.Match(.Value2, varNumeric, 0))
If Not IsError(varResult) Then
cell.Value2 = varResult
Else:
If Not IsMissing(varNoMatch) Then cell.Value2 = varNoMatch
End If
End With
Next cell
errHandler:
If Err.Number > 0 Then
If gbDebug Then
Stop: Resume
Else:
MsgBox "Whoops, there was an error: Error#" & Err.Number & vbCrLf & Err.Description _
, vbCritical, "Error", Err.HelpFile, Err.HelpContext
End If
End If
With Application
.ScreenUpdating = bScreenUpdating
.EnableEvents = bEnableEvents
.Calculation = lngCalculation
End With
End Function
そして、ここではその結果です:VALUESエリア内のテキストを持つピボットテーブル:

はここで何にコードを告げる「変換」テーブルです各番号の表示:

私のコードkのように私は、これらの2つの名前付き範囲が割り当てられていますNOWSルックアップテーブルを検索するには:
- tbl_PivotValues.TextValue
- ここtbl_PivotValues.NumericValue
...と私は機能を起動し、必要な引数を渡す方法は次のとおりです。
Option Explicit
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
If Target.Name = "GroupView" Then Pivots_TextInValuesArea Target, [tbl_PivotValues.NumericValue], [tbl_PivotValues.TextValue]
End Sub
このコードは、ワークシートコードモジュールにあり、ピボットテーブルがあるワークシートに対応しています。

[タイトルにタグを使用する必要がありますか?](http://meta.stackexchange.com/help/tagging)を参照してください。 – pnuts
私はあなたの編集に正直に同意しません。私のタイトルを編集したのは、質問がExcel、SQL、または利用可能なソフトウェアや言語のどれかを指しているのかどうかを理解することは不可能です。あなたは「Excel:Pivot」(小柄なものは小さな心を楽しませる)ではなく「Pivot [...]をExcelで書くことができると主張するかもしれませんが、タイトルのExcelを言及することが重要であると確信しています。あまりにもあいまいです。 –
自由にロールバックしてください。しかし、あなたの投稿はタグからのExcelに関するものであり、Titlesの限られたスペースは、75k +他のExcel Qの間ではなく、あなたのQを他の人と区別するのに適しています。つまり、私はあなたのQを際立たせようとしていました - クイック/クオリティーレスポンスのより良いチャンスかもしれませんが、あなたが「ブレンドする」ことを好むなら、それは私のものです。 – pnuts