Hi
Re: Excel 2003
I have just started utilising Pivot Tables so am very new to it, however I have set up one table and have then recorded a macro so that I can run the macro to do the table whenever I have a new report. The contents of the reports are the same however the amount of data varies.
The issue I have is that in the macro it identifies the cell ranges, however all my reports are different sizes. Is it possible to replace the cell range with a reference??? so that it automatically identifies the whole table regardless of size? See macro below.
Also while I’m on a roll, is it possible to include in the macro the option to bold and change the colour of the data in row and or column totals ?
Thanks in advance for your assistance
Cheers
Dax
Sub Pivot_report()
‘
‘ Pivot_report Macro
‘ Macro recorded 15/04/2011 by KuilboFY
‘
‘ Keyboard Shortcut: Ctrl+p
‘
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
“contract_extract!R1C1:R28C22“).CreatePivotTable TableDestination:=””, _
TableName:=”PivotTable1″, DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables(“PivotTable1”).PivotFields(“familyname”).Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables(“PivotTable1”).PivotFields(“firstname”).Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
ActiveSheet.PivotTables(“PivotTable1”).AddFields RowFields:=Array(“client_id” _
, “familyname”, “firstname”, “course_id”, “module_id”), ColumnFields:= _
“modoutcome”
ActiveSheet.PivotTables(“PivotTable1”).PivotFields(“module_hrs_super”). _
Orientation = xlDataField
End Sub