Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default Sort Pivot Table by Gran total automaticaly

How do I sort my pivot table by the grand total...? I can do it manualy but
if I change the criteria I loose the sorting and have to select all the data
and manually sort it again.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Sort Pivot Table by Gran total automaticaly

If you can do it manually, just turn on the macro recorder before running
through the steps. When you are done with the sort, turn off the macro
recorder and view the code by hitting Alt+F11 on your keyboard.
Also, compare your recorder code to this code:
Sheets("Sheet1").Select
Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
Sheets("Sheet1").Range("A1").CurrentRegion).Create PivotTable _
TableDestination:=Sheets("Sheet2").Range("A3"),
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10

Pay attention to this part:
Sheets("Sheet1").Range("A1").CurrentRegion).

You will need to replace your recorded code with that snippet of code
(change the sheet name so it matches yours). That will give you a dynamic
range; you always capture all the data for your Pivot Table. Otherwise, you
will have a fixed (or absolute range) and if you have more data than what is
in the recorded macro, you will miss what is at the bottom; quite simply your
Pivot Table will display incorrect results.

Give it a go and let me know how it works out for you!!

HTH,
Ryan---



--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Alberto Ast" wrote:

How do I sort my pivot table by the grand total...? I can do it manualy but
if I change the criteria I loose the sorting and have to select all the data
and manually sort it again.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Sort Pivot Table by Gran total automaticaly

This is what I get from my macro

Range("A6:D189").Select
Range("D6").Activate
Selection.Sort Key1:="R6C4", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Range("E1").Select

Would you gave me the complete set up... I have not much experience using
the macros on the view code where I think is where it should go.

Thanks
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
Duplicate Running Total Grand Total In Pivot Table Mathew P Bennett[_2_] Excel Discussion (Misc queries) 1 August 17th 08 03:13 AM
sort by grand total in pivot table joemeshuggah Excel Programming 0 August 6th 08 07:12 PM
How do I sort a Piviot table by the Total field in Excel 2002 [email protected] Charts and Charting in Excel 1 September 13th 07 10:28 PM
Showing Pivot Table total on Associated Pivot Chart KenY Excel Discussion (Misc queries) 2 May 18th 07 02:41 PM
% 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 07:31 AM.

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

About Us

"It's about Microsoft Excel"