VictoriaLJones
Technical User
I am trying to generate a pivot table in order to run some comparisons between 2 sets of reports. However - I have recorded generating a pivot table via the recorder, but when I have come to re-run the macro it falls over with 40036 - Application-defined or Object-defined error, with no debug option. I have managed to ascertain that it is the AddFields code that is falling over. Having never used 2002 before (97 the norm) can anyone tell me if I am doing something wrong...
I have copied the relevant code below.
Any suggestions would be gratefully received! (Oh and apologies for the clumsiness of the code!!)
Many thanks
Victoria
Workbooks.Open Filename:= _
"C:\Documents and Settings\carla\My Documents\Credit Lyonnais_old.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\carla\My Documents\Credit Lyonnais_new.xls"
Windows("Credit Lyonnais_New.xls"
.Activate
'Range("H1"
.Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Sub-Acct 1'!R4C1:R87C6"
.CreatePivotTable TableDestination:= _
"'[Credit Lyonnais_new.xls]Sub-Acct 1'!R3C8", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTables("PivotTable1"
.AddFields RowFields:=Array( _
"Fund Family", "Ticker", "Shares", "NAV", "Market Value"
ActiveSheet.PivotTables("PivotTable1"
.PivotFields("Fund Name"
.Orientation = _
xlDataField
ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable"
.Visible = False
Range("I8"
.Select
Application.PivotTableSelection = True
ActiveSheet.PivotTables("PivotTable1"
.PivotSelect "Ticker[All;Total]", _
xlDataAndLabel, True
I have copied the relevant code below.
Any suggestions would be gratefully received! (Oh and apologies for the clumsiness of the code!!)
Many thanks
Victoria
Workbooks.Open Filename:= _
"C:\Documents and Settings\carla\My Documents\Credit Lyonnais_old.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\carla\My Documents\Credit Lyonnais_new.xls"
Windows("Credit Lyonnais_New.xls"
'Range("H1"
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'Sub-Acct 1'!R4C1:R87C6"
"'[Credit Lyonnais_new.xls]Sub-Acct 1'!R3C8", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTables("PivotTable1"
"Fund Family", "Ticker", "Shares", "NAV", "Market Value"
ActiveSheet.PivotTables("PivotTable1"
xlDataField
ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable"
Range("I8"
Application.PivotTableSelection = True
ActiveSheet.PivotTables("PivotTable1"
xlDataAndLabel, True