title: Function to test if a pivot field's subtotals are visible
body: <p>I want a function that tells me if a pivot field's subtotals are visible. For example, in this pivot table both Region and Item have subtotals turned on...</p>
  
  <p><a href="https://i.stack.imgur.com/urMkS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/urMkS.jpg" alt="enter image description here"></a></p>
  
  <p>... but only the Region subtotals are showing, which makes sense. I want a function that returns true if the passed field's subtotals are actually shown in the pivot table.</p>
  
  <p>This function takes a pivot field as its argument and returns whether subtotals are turned on. It returns true for both Region and Item fields since they both have subtotals turned on:</p>
  
  <pre><code>Function PivotFieldSubtotalsOn(pvtField As Excel.PivotField) As Boolean
  Dim i As Long
  
  For i = 1 To 12
      If pvtField.Subtotals(i) = True Then
          PivotFieldSubtotalsOn = True
          Exit Function
      End If
  Next i
  End Function
  </code></pre>
  
  <p>Instead I want it to return False for Item in the situation above since Item subtotals aren't actually shown.</p>
  
  <p>I thought about checking whether the Field name and the word "Total" appear in a cell in the pivot table, but subtotal labels can be changed. My best guess is to add a test whether a field <code>Position</code> is not the last one for its <code>Orientation</code>, since subtotals don't show up in that case.</p>