Excel 2000 - 2003 Compatability problem with pivottables

G

gromit12

Hi,

I came up with some code that creates a pivottable just the way I want
it in Excel 2003. However, the code throws an error in Excel 2000 at
the 'AddDataField' part. I've tried and tried to recreate the same
effect in 2000 - anyone got any idea what the equivalent work around
code would be?

Thanks for any help


Sub CreatePT()

Set wksD.Range("rDataRangeCorner").CurrentRegion.Name = "rSourceData"

ThisWorkbook.PivotCaches.Add(SourceType:=xlDatabase,
SourceData:="=rSourceData") _
.CreatePivotTable TableDestination:="=rDestination", _
TableName:="PivotTable1"

Set ptPivot = wksP.PivotTables("PivotTable1")

With ptPivot
.ColumnGrand = False
.PivotFields("Date").Orientation = xlRowField
.PivotFields("Description").Orientation = xlRowField
.PivotFields("P").Orientation = xlPageField
.PivotFields("Month").Orientation = xlPageField
.AddDataField ptPivot.PivotFields("Hours"), "Sum of Hours",
xlSum
.PivotFields("Value").Orientation = xlColumnField
.AddDataField ptPivot.PivotFields("Value"), "Sum of Value",
xlSum
.DataPivotField.Orientation = xlColumnField

'Weird code to get rid of row subtotals
.PivotFields("Date").Subtotals = Array(False, False, _
False, False, False, False, False, False, False, False, False,
False)

End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top