Results 1 to 1 of 1

Thread: [RESOLVED]Excel Pivot table from Access

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    48

    Resolved [RESOLVED]Excel Pivot table from Access

    Im still making a 'Sanctions' Database for the school i work at, however to make the creation of graphs more flexible for the different outputs i was going to use a pivot table and chart... currently i have this code:

    VB Code:
    1. 'Pivot Table and Chart start
    2.     oWS.Activate
    3.     oWS.Range("B2:I" & i - 1).Select
    4.     oWB.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    5.         "TempTable!R1C1:R11C8").CreatePivotTable TableDestination:= _
    6.         "[Year_10_09_12_2005.xls]TempTable!R20C1", TableName:="PivotTable2", _
    7.         DefaultVersion:=xlPivotTableVersion10
    8.     With oWS.PivotTables("PivotTable1")
    9.         .ColumnGrand = False
    10.         .RowGrand = False
    11.     End With
    12.     oWS.PivotTables("PivotTable2").AddFields RowFields:="Sanction", _
    13.         ColumnFields:="Name", PageFields:="Date"
    14.     oWS.PivotTables("PivotTable2").PivotFields("Sanction").Orientation = _
    15.         xlDataField
    16.     Dim oPivotChart As Excel.Chart
    17.     Set oPivotChart = oApp.Charts.Add()
    18.     oPivotChart.SetSourceData Source:=Sheets(tTempMain).Range("A" & i + 6)
    19.     oPivotChart.location Where:=xlLocationAsNewSheet
    20.    
    21.     'Pivot Table and Chart End

    where oWS is the current sheet and oWB is the Current Workbook, this doesnt seem to work for some reason though. Any ideas?
    Last edited by c03cg; Mar 7th, 2006 at 04:47 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width