Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Get grand total from pivot table

Hello All,

Thank you for your help in the past. I'm here with another question.

I need code to get the grand total of the row totals in a pivot table. Using
this grand total, I would need to delete the sheet (each sheet has only one
pivot table) if the grand total is zero.

I don't know what the name of the pivot table is, but I know for sure each
sheet that the macro is run on will have only one pivot table. Each pivot
table does have a row and column titled "Grand Total" and the grand total
that I need is the summation of the totals of each individual row. The pivot
table does have this data displayed on most bottom right.

Any help would be greatly appreciated.

-Karim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Get grand total from pivot table

Karim,

Try the macro below.

HTH,
Bernie
MS Excel MVP


Sub Macro1()

Dim mySht As Worksheet

On Error GoTo NoPT
With Application
.EnableEvents = False
.DisplayAlerts = False
End With

For Each mySht In ActiveWorkbook.Worksheets
mySht.Select
mySht.PivotTables(1).PivotSelect "", xlDataAndLabel, True
If Selection.Cells(Selection.Cells.Count).Value = 45 Then
mySht.Delete
End If

NextSht:
Next mySht

With Application
.EnableEvents = True
.DisplayAlerts = True
End With

Exit Sub

NoPT:
Resume NextSht
End Sub


"karimhemani" wrote in message
...
Hello All,

Thank you for your help in the past. I'm here with another question.

I need code to get the grand total of the row totals in a pivot table. Using
this grand total, I would need to delete the sheet (each sheet has only one
pivot table) if the grand total is zero.

I don't know what the name of the pivot table is, but I know for sure each
sheet that the macro is run on will have only one pivot table. Each pivot
table does have a row and column titled "Grand Total" and the grand total
that I need is the summation of the totals of each individual row. The pivot
table does have this data displayed on most bottom right.

Any help would be greatly appreciated.

-Karim



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Get grand total from pivot table

Sorry, the 45 should be 0

If Selection.Cells(Selection.Cells.Count).Value = 45 Then
mySht.Delete
End If

Should have been

If Selection.Cells(Selection.Cells.Count).Value = 0 Then
mySht.Delete
End If

My test Pivot Table had 45 as the Grand Total.....

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Karim,

Try the macro below.

HTH,
Bernie
MS Excel MVP


Sub Macro1()

Dim mySht As Worksheet

On Error GoTo NoPT
With Application
.EnableEvents = False
.DisplayAlerts = False
End With

For Each mySht In ActiveWorkbook.Worksheets
mySht.Select
mySht.PivotTables(1).PivotSelect "", xlDataAndLabel, True
If Selection.Cells(Selection.Cells.Count).Value = 45 Then
mySht.Delete
End If

NextSht:
Next mySht

With Application
.EnableEvents = True
.DisplayAlerts = True
End With

Exit Sub

NoPT:
Resume NextSht
End Sub


"karimhemani" wrote in message
...
Hello All,

Thank you for your help in the past. I'm here with another question.

I need code to get the grand total of the row totals in a pivot table. Using
this grand total, I would need to delete the sheet (each sheet has only one
pivot table) if the grand total is zero.

I don't know what the name of the pivot table is, but I know for sure each
sheet that the macro is run on will have only one pivot table. Each pivot
table does have a row and column titled "Grand Total" and the grand total
that I need is the summation of the totals of each individual row. The pivot
table does have this data displayed on most bottom right.

Any help would be greatly appreciated.

-Karim





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
pivot table grand total Kardal Excel Discussion (Misc queries) 1 October 21st 08 06:49 PM
Duplicate Running Total Grand Total In Pivot Table Mathew P Bennett[_2_] Excel Discussion (Misc queries) 1 August 17th 08 03:13 AM
Pivot Table Grand Total Stonewall Excel Discussion (Misc queries) 3 June 12th 07 12:25 AM
Grand total in Pivot-Table TaiwanSwede Excel Worksheet Functions 0 January 10th 06 03:03 AM
% of Running Total to Grand Total in Pivot Table David Excel Programming 0 August 17th 05 08:24 PM


All times are GMT +1. The time now is 11:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"