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:
'Pivot Table and Chart start oWS.Activate oWS.Range("B2:I" & i - 1).Select oWB.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _ "TempTable!R1C1:R11C8").CreatePivotTable TableDestination:= _ "[Year_10_09_12_2005.xls]TempTable!R20C1", TableName:="PivotTable2", _ DefaultVersion:=xlPivotTableVersion10 With oWS.PivotTables("PivotTable1") .ColumnGrand = False .RowGrand = False End With oWS.PivotTables("PivotTable2").AddFields RowFields:="Sanction", _ ColumnFields:="Name", PageFields:="Date" oWS.PivotTables("PivotTable2").PivotFields("Sanction").Orientation = _ xlDataField Dim oPivotChart As Excel.Chart Set oPivotChart = oApp.Charts.Add() oPivotChart.SetSourceData Source:=Sheets(tTempMain).Range("A" & i + 6) oPivotChart.location Where:=xlLocationAsNewSheet '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?


Reply With Quote