Hi, It will be easy to solve issue if you provide sample data.
In your code you have not defined DataField, without data field it will show you blank pivot. Share sample data so that group can provide you correct code. Regards, Swapnil. On Wed, Oct 26, 2011 at 10:07 AM, Chan Darwin <darwin.chankaw...@gmail.com>wrote: > 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. > > "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!! > > Darwin Chan > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/discussexcel > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel