Private Sub Workbook_SheetPivotTableUpdate(ByVal Sh As Object, ByVal Target As PivotTable)

    Dim 필드 As PivotField
    Dim 총합계 As Double
    
    For Each 필드 In Target.DataFields
    
        If 필드.Function = xlCount Then
        
            Application.EnableEvents = False
    
                필드.Function = xlSum
                
                With Target.DataBodyRange
                
                    총합계 = .Cells(.Count).Value
                    
                    If 총합계 = 0 Then 필드.Function = xlCount
                    
                End With
            
            Application.EnableEvents = True
            
        End If
    
    Next
    
End Sub
