Function GetGrandTotalCell(pt As PivotTable, Optional RowOrCol As Integer = 1) As Range
Dim rng As Range
If RowOrCol = 1 Then
Set rng = pt.RowRange
ElseIf RowOrCol = 2 Then
Set rng = pt.ColumnRange
Else
Exit Function
End If
With rng
Set GetGrandTotalCell = .Cells(.Cells.Count)
End With
End Function