Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with Pivot Table

Hi,

I need some help with pivot tables:

Given a pivot table, and a selected cell within it, is there any way I can
find out the Column Label and Row Label values that the cell is in? There's
just so many functions in the PivotTable object model (get_HiddenFields,
get_ColumnFields, get_DataFields, etc), and I've no idea where to start.

| Column Labels
| columnA | columnB |
Item1 | 6 | 2 |
+ rowA | 2 | 2 |
+ rowB | 4 | |
Item2 | 3 |12 |
+ rowB | | 4 (A) |
+ rowC | 3 | 8 |
Total | 9 | 14 |

Not sure if the diagram will load up correctly. If it does, assume that cell
(A) is selected, and hence, I'm trying to get "Item2", "rowB" and "columnB".

If the diagram is not formatted correctly, I've uploaded the image he

http://img58.imageshack.us/img58/6053/pivottablesy5.png

Please help.

Thanks


Josh

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Help with Pivot Table

You can always double-click on selected cell so data that stands behind that
firgure will be displayed. I dont know if it helps.

S.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with Pivot Table

Hi Snake,
thanks for the attempt. However, there's a reason why I posted this in the
excel.programming newsgroup. :) Trying to figure out how to do this
programmatically (I'm fine with C# or VBA code). I'm using C# and the Excel
Object Model 2007.

Thanks again

Josh

"Snake Plissken" wrote:

You can always double-click on selected cell so data that stands behind that
firgure will be displayed. I dont know if it helps.

S.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Help with Pivot Table

did you try to analyze auto-recorded makro during which the data is shown? I
know - this might be a childish answer but still there is a reason to start
with the simpliest solution ;)


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with Pivot Table

Sorry, have no idea what that is or how to do it. Can you walk me through it?

Thanks


"Snake Plissken" wrote:

did you try to analyze auto-recorded makro during which the data is shown? I
know - this might be a childish answer but still there is a reason to start
with the simpliest solution ;)





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Help with Pivot Table

Hi everyone,

After going through (and testing) almost every class in the Excel 2007
reference doc that contains the word "Pivot", I think I've finally figured
out how to get the labels:

// Selected cell (in this case, the active cell)
PivotCell cell = Application.ActiveCell.PivotCell;

PivotItemList pivotRow = cell.RowItems;
PivotItemList pivotColumn = cell.ColumnItems;

// Retrieve row labels
for (int i = 1; i <= pivotRow.Count; i++)
rowLabels.Add(pivotRow.Item(i).Caption);

// Retrieve column labels
for (int i = 1; i <= pivotColumn.Count; i++)
columnLabels.Add(pivotColumn.Item(i).Caption);

Man, it was really hard to figure this one out, especially when I didn't
know all the terms and keywords.

In any case, hope this will help anyone who needs it in the future. If this
is the wrong approach, please let me know too.

Thanks!

Josh
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Help with Pivot Table

If you have MS Office 2003 or older then you have to chose
"Tools-macro-Record New Macro". Then you have to proceed with things you
would like to do programatically ( but still you do it manually ). After
it's done you have to stop recording the macro in the same place you started
it. Then you have to analize the code generated automatically by excel. The
only thing you need is to optimize it or change it according to your needs.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Help with Pivot Table

yeah - you may go through the references, classess etc ro try to analize
automatic code I told you some minutes ago. Depending on the situation it
might bring good results as well.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Pivot Table

Have you found a way to get a full list of all DataFields ?

"JsJ_Slim" wrote:

Hi everyone,

After going through (and testing) almost every class in the Excel 2007
reference doc that contains the word "Pivot", I think I've finally figured
out how to get the labels:

// Selected cell (in this case, the active cell)
PivotCell cell = Application.ActiveCell.PivotCell;

PivotItemList pivotRow = cell.RowItems;
PivotItemList pivotColumn = cell.ColumnItems;

// Retrieve row labels
for (int i = 1; i <= pivotRow.Count; i++)
rowLabels.Add(pivotRow.Item(i).Caption);

// Retrieve column labels
for (int i = 1; i <= pivotColumn.Count; i++)
columnLabels.Add(pivotColumn.Item(i).Caption);

Man, it was really hard to figure this one out, especially when I didn't
know all the terms and keywords.

In any case, hope this will help anyone who needs it in the future. If this
is the wrong approach, please let me know too.

Thanks!

Josh

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
how to create pivot table from existing pivot table in excel 2007 Udayraj Dhulekar Excel Discussion (Misc queries) 2 July 8th 13 08:22 PM
Copying values from pivot table to cells outside pivot table richzip Excel Discussion (Misc queries) 4 January 16th 08 11:03 PM
Filter lines containing pivot table and non pivot table data Grover Excel Worksheet Functions 0 September 24th 07 07:20 PM
How do I create a pivot table if the pivot table icon or menu ite. Lynn@WS Charts and Charting in Excel 1 December 16th 04 02:36 AM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana[_5_] Excel Programming 0 August 21st 03 10:19 PM


All times are GMT +1. The time now is 05:26 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"