Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Pivot Table error (424)

I am setting up pivot tables in my worksheet and using the following code I
get the Run-time error '424' Object required. When I click on Debug, it
highlights the "Set WSD..." line. Thanks in advance.

Sub PivotTable()

Dim WSD As Worksheet
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim PRange As Range
Dim FinalRow As Long
Set WSD = Worksheets("Pivot Table")

' Delete any prior pivot tables
For Each PT In WSD.PivotTables
PT.TableRange2.Clear
Next PT
'Define input area and set up a Pivot Cache
FinalRow = WSD.Cells(65536, 1).End(lxUp).Row
Set PRange = WSD.Cells(1, 1).Resize(FinalRow, 8)
Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=PRange.Address)
Set PT = PTCache.CreatePivotTable(TableDestination:=WSD.Ran ge("M5"), _
TableName:="PivotTable1")
PT.ManualUpdate = True
' Set up the row and column fields.
PT.AddFields RowFields:=Array("Product", "Customer"), ColumnFields:="Region"
' Set up the data fields
With PT.PivotFields("Revenue")
.Orientation = xlDataField
.Function = xlSum
.Postion = 1
End With
'Calc the pivot table
PT.ManualUpdate = False
PT.ManualUpdate = True

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table #VALUE! Error ! Tufail Excel Discussion (Misc queries) 2 October 15th 09 05:15 PM
XML error in Pivot Table Twlvman8 Excel Discussion (Misc queries) 0 February 11th 09 05:03 PM
Pivot Table #Name? error Dave Excel Discussion (Misc queries) 2 July 26th 07 02:22 PM
Pivot Table Error Maral Excel Discussion (Misc queries) 1 July 4th 05 06:20 PM
Pivot Table Error Linda Excel Programming 1 December 2nd 03 04:37 PM


All times are GMT +1. The time now is 09:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"