Dear all,
I wrote the code in creating pivot table for my source of data.
However, when run the code, it prompts with the message. (I use Excel 2000)
"Run-time error '438':
Object doesnt support this property or method"
Below please find the code also.
****************************
Sub CreatePivotTable()
Dim PTCache As PivotCache
Dim PT As PivotTable
Application.ScreenUpdating = False
'Add a new sheet for the pivot table
Worksheets.Add
'Create the cache
Set PTCache =
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,
SourceData:=Range("A1").CurrentRegion.Address)
'Create the pivot table
Set PT = ActiveSheet.PivotTables.Add(PivotCache:=PTCache,
TableDestination:=Range("A3"))
'Specify the fields
With PT
.PivotFields("street").Orientation = xlColumnField
.PivotFields("condition_code").Orientation = xlColumnField
.PivotFields("customer_code").Orientation = xlRowField
.PivotFields("liner_code").Orientation = xlRowField
.PivotFields("cont_type_code").Orientation = xlRowField
.DisplayFieldCaptions = False
End With
Application.ScreenUpdating = True
End Sub
****************************
Thanks in advance!!
kw42Chan
I wrote the code in creating pivot table for my source of data.
However, when run the code, it prompts with the message. (I use Excel 2000)
"Run-time error '438':
Object doesnt support this property or method"
Below please find the code also.
****************************
Sub CreatePivotTable()
Dim PTCache As PivotCache
Dim PT As PivotTable
Application.ScreenUpdating = False
'Add a new sheet for the pivot table
Worksheets.Add
'Create the cache
Set PTCache =
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,
SourceData:=Range("A1").CurrentRegion.Address)
'Create the pivot table
Set PT = ActiveSheet.PivotTables.Add(PivotCache:=PTCache,
TableDestination:=Range("A3"))
'Specify the fields
With PT
.PivotFields("street").Orientation = xlColumnField
.PivotFields("condition_code").Orientation = xlColumnField
.PivotFields("customer_code").Orientation = xlRowField
.PivotFields("liner_code").Orientation = xlRowField
.PivotFields("cont_type_code").Orientation = xlRowField
.DisplayFieldCaptions = False
End With
Application.ScreenUpdating = True
End Sub
****************************
Thanks in advance!!
kw42Chan