'Title: 'Setting the number of Decimal digits of each percentages in a Pivot Table 'Description: 'Q. 'I'm using SPSS 7.5 or higher. 'I would like to set the number of Decimal digits displayed in a Pivot Table. 'Is there a way to automate this? 'A. 'Below is a script which will make the changes for the currently selected Pivot Table. 'Sub Main may be modified or discarded; however, the SetDecimalDigits subroutines, 'Function will probably not need modification should you wish to use them in your own 'scripts, or Call them from an Autoscript routine. 'This script is a modification of AnswerNet Solution ID: 100007757 'Posted to SPSSX-L list by Raynald Levesque on 2003/03/11 'Begin Description 'SetDecimalDigits sets cell formats of all percentages to the specified number of digits. 'End Description Sub Main() Dim objPivot As PivotTable Dim objItem As ISpssItem Dim bolFoundOutputDoc As Boolean Dim bolPivotSelected As Boolean 'Pivot table must be activated Call GetFirstSelectedPivot(objPivot, objItem, bolFoundOutputDoc, bolPivotSelected) If (bolFoundOutputDoc = False) Or (bolPivotSelected = False) Then 'either there wasn't an output doc or a pivot table wasn't selected Exit Sub End If 'postpone drawing until we're finished objPivot.UpdateScreen = False 'set all cell formats to 2 decimal digits Call SetDecimalDigits(objPivot, 2) objPivot.UpdateScreen = True objItem.Deactivate 'sometimes, the PivotTable Height and Width are not updated correctly 're-activating the table will work around this objItem.ActivateTable objItem.Deactivate End Sub Sub SetDecimalDigits(objPivot As PivotTable, intDigits As Integer) 'Changes the number of Decimal Digits for *all* cells containing "%" Dim lngRow As Long, lngCol As Long Dim objDataCells As ISpssDataCells Set objDataCells = objPivot.DataCellArray With objDataCells For lngRow = 0 To .NumRows - 1 For lngCol = 0 To .NumColumns - 1 If Not IsNull (.ValueAt (lngRow, lngCol)) And InStr(.NumericFormatAt(lngRow,lngCol),"%")>0 Then .HDecDigitsAt (lngRow, lngCol) = intDigits End If Next Next End With objPivot.Autofit End Sub