Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default pivate tables

Hi;
Is there a way of accessing pivate tables from an excel spreadsheet in code?
Any help apreciated.
Sean.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default pivate tables

Sean,

Here's some code I put in a worksheet module to try to learn the various VBA
properties of pivot tables. Maybe it will help you:

Sub PivotProperties()
Dim ws As Worksheet
Dim pvt As PivotTable
Dim pvtColumnField As PivotField
Dim pvtVisibleField As PivotField
Dim pvtItem As PivotItem
Dim pvtVisibleItem As PivotItem
Dim rngGrandTotalRow As Range
Dim rngGrandTotalCol As Range
Dim i As Long
Dim j As Long

Set ws = ActiveSheet
Set pvt = ws.PivotTables(1)
With pvt
For i = 1 To .VisibleFields.Count
Set pvtVisibleField = .VisibleFields(i)
With pvtVisibleField
Debug.Print vbCrLf & .Name & " Label range: " &
..LabelRange.Address & ":"
'all items, visible or hidden
For j = 1 To .PivotItems.Count
Set pvtItem = .PivotItems(j)
With pvtItem
Debug.Print .Name & " "
End With
Next j
'only visible items
For j = 1 To .VisibleItems.Count
Set pvtItem = .VisibleItems(j)
With pvtItem
Debug.Print .Name & " "; .DataRange.Address
End With
Next j
End With
Next i
Set rngGrandTotalRow = .DataBodyRange.Offset(.DataBodyRange.Rows.Count -
1, 0).Resize(1, .DataBodyRange.Columns.Count - 1)
Set rngGrandTotalCol = .DataBodyRange.Offset(0,
..DataBodyRange.Columns.Count - 1).Resize(.DataBodyRange.Rows.Count - 1, 1)
Debug.Print "Grand Total Column:" & rngGrandTotalCol.Address
Debug.Print "Grand Total Row:" & rngGrandTotalRow.Address
End With

End Sub

Doug

"Sean Farrow" wrote in message
...
Hi;
Is there a way of accessing pivate tables from an excel spreadsheet in
code?
Any help apreciated.
Sean.



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
concatenate tables into html tables urlocaljeweler Excel Discussion (Misc queries) 1 December 11th 09 08:15 PM
concatenate tables into html tables urlocaljeweler New Users to Excel 1 December 11th 09 06:30 AM
Excel tables vs. system tables FUBARinSFO[_2_] Excel Programming 3 January 27th 08 09:13 PM
Any way to programmatically make pivot tables behave more like data tables? Ferris[_2_] Excel Programming 1 August 24th 07 06:20 PM
Extracting/Exporting HTML Tables or PDF Tables into Excel [email protected] Excel Programming 3 July 25th 06 09:57 AM


All times are GMT +1. The time now is 08:05 PM.

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"