2013-03-11 45 views
0
 
ParentName Designation offsite  onsite total 
ASP   ASE     1     1 
       SE     2   2  4 
       ITA     3   7  10 
       AssSE    **2**   2  4 
ASP Total       8   11  19 
ESP   ITA    15     15 
       AssC    2     2 
       AssSE    1     1 
ESP Total      18     18 
IS-TP   ASE     7     7 
       AssSE    **19**     19 
       SE     32     32 
       BA     1   3  4 
       ITA    24   11  35 
IS-TP Total      83   14  97 
Grand Total      109   25  134 

在這種透視表中的星標記的單元值可基於樞軸數據來概括總結根據病情樞軸項數據。如何獲取數據透視數據並根據指定數值求和。即如果指定是Asst.system工程師,並且Parent IOU Name是「Is-Telecom-parent」和Assurance Services-1Parent,則獲得非現場總數並將它們彙總爲使用VBA的excel中的結果。如何使用Excel VBA

**提供VBA代碼

+0

你不能簡單地修改樞軸或創建的第二樞軸 - 與「稱謂」作爲第一個行字段?或者,試試這個公式:'= SUMIFS($ C:$ C,$ B:$ B,「AsstSystems Engineer」)' – 2013-03-11 08:22:01

+0

在某些數據透視表中,其他父級名稱而不是ASP和IS-TP有AsstSystems Engineer。但我只需要從ASP和IS-TP異地值中彙總數據 – user2119252 2013-03-12 06:54:06

+0

如果你在VBA中需要這個,你仍然可以使用SUMIFS公式:'strSearch =「AsstSystemsEngineer」):Debug.Print WorkhseetFunction.Sumifs(Range(「C: C「),範圍(」B:B「),strSearch)' – 2013-03-12 08:13:21

回答

0

試試這個代碼:

Sub SumSelectedPivotElements() 
    Dim piv As PivotTable 
    Dim res As Double 

    Set piv = Sheets("YourSheet").PivotTables(1) 'Replace with correct sheetname 

    'Replace "Location" with your column field name 
    res = piv.GetPivotData("Name of your data field", "ParentName", "IS-TP", "Designation", "AssSE", "Location", "offsite") 
    res = res + piv.GetPivotData("Name of your data field", "ParentName", "IS-TP", "Designation", "AssSE", "Location", "offsite") 
    Debug.Print "The result is: ", res 
End Sub 
+0

k謝謝..我需要根據條件檢查父母名稱。因爲如果我使用上面的代碼,它不適用於IS-TP只有AssSE的另一個數據。我需要哪些有史以來excel dat我基於父母的名字工作。 – user2119252 2013-03-12 13:01:36