Sub ConvertDataFieldsNumberFormat()
Dim strField As String, strNumFormat As String, strNumFormatDef As String
Set PT = Nothing
strNumFormatDef = "#,##0"
On Error Resume Next
Set PT = ActiveCell.PivotCell.PivotTable
On Error GoTo 0
If PT Is Nothing Then
MsgBox "Not in a Pivot Table"
Exit Sub
End If
strField = Application.InputBox("Enter the search term for the Pivot Fields to be changed:" & _
vbCr & vbCr & "(leave blank to change all Pivot Fields)", strTitle, Type:=2)
If strField = "False" Then Exit Sub
strNumFormat = Application.InputBox("Enter the number format to apply to the Pivot Fields:" & _
vbCr & vbCr & "leaving this blank will default to ""#,##0"", e.g. 1,000", strTitle, strNumFormatDef, Type:=2)
If strNumFormat = "False" Then Exit Sub
If strNumFormat = "" Then strNumFormat = strNumFormatDef
'you could turn off Screenupdating, Pivot table updating here if it runs slowly
For Each PF In PT.DataFields
If InStr(1, PF.Name, strField) <> 0 Then
PF.NumberFormat = strNumFormat
End If
Next PF
'and turn it back on again here
End Sub