Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Run Time Error '1004'

Hi ,

Any help is appreciated. It was working fine on another Data set and all i
did is to change the List values and now I am getting this error :

Run Time Error '1004'

Unable to Set _Default property on PivotItem class

background:

I am running a loop where it looks at a list of values on another worksheet
and Pivot Tables Runs through the loop and copies and paste the Pivot Result
Set in another worksheet and Goes to the next Value in the list and so on.

here is my Code:


Dim pvtField As PivotField
Dim iCount As Integer


'SM add
pastefromstartcolumn = 1
pastefromendcolumn = 123
pastefromstartrow = 5
pastefromendrow = Cells(65536, 1).End(xlUp).Row


'SM quick add- need to define this b/f loop starts
'defining as zero, b/c it will be established as +1 every time
pastetostartrow = 1
Worksheets("Pasted Results").Activate
Cells.Delete
Worksheets("Ranking Incl ZZ").Activate
'paste headers first
Range(Cells(4, pastefromstartcolumn), Cells(4, pastefromendcolumn)).Copy
Worksheets("Pasted Results").Activate
Cells(pastetostartrow, 1).Select
Selection.PasteSpecial xlValues
Worksheets("Ranking Incl ZZ").Activate


Set pvtTable = Worksheets("Ranking Incl ZZ").PivotTables("PivotTable1")
Set pvtField = pvtTable.PivotFields("AA_name")

For iCount = 0 To 101

pvtField.CurrentPage = _
Worksheets("AAList").Range("AA_List").Offset(iCoun t, 0).Value

pastefromstartrow = 5
pastefromendrow = Cells(65536, 1).End(xlUp).Row

'SM add
'now the loop
For celltopaste = pastefromstartrow To pastefromendrow
'aa copy
Cells(1, 2).Copy Destination:=Worksheets("Pasted
Results").Cells(pastetostartrow + 1, 1)
'selecting the results of the pivottable (and the two ranking columns to the
right of it
Range(Cells(celltopaste, pastefromstartcolumn), Cells(celltopaste,
pastefromendcolumn)).Copy
Worksheets("Pasted Results").Activate
Cells(pastetostartrow + 1, 2).Select
Selection.PasteSpecial xlValues
Worksheets("Ranking Incl ZZ").Activate
'this variable will change after every paste
pastetostartrow = Worksheets("Pasted Results").Cells(65536, 1).End(xlUp).Row
Next celltopaste



Next iCount
Response = MsgBox("Task Complete")
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Run Time Error '1004'

Any help is appreciated? Did i post in the wrong section?

"sumnesh" wrote:

Hi ,

Any help is appreciated. It was working fine on another Data set and all i
did is to change the List values and now I am getting this error :

Run Time Error '1004'

Unable to Set _Default property on PivotItem class

background:

I am running a loop where it looks at a list of values on another worksheet
and Pivot Tables Runs through the loop and copies and paste the Pivot Result
Set in another worksheet and Goes to the next Value in the list and so on.

here is my Code:


Dim pvtField As PivotField
Dim iCount As Integer


'SM add
pastefromstartcolumn = 1
pastefromendcolumn = 123
pastefromstartrow = 5
pastefromendrow = Cells(65536, 1).End(xlUp).Row


'SM quick add- need to define this b/f loop starts
'defining as zero, b/c it will be established as +1 every time
pastetostartrow = 1
Worksheets("Pasted Results").Activate
Cells.Delete
Worksheets("Ranking Incl ZZ").Activate
'paste headers first
Range(Cells(4, pastefromstartcolumn), Cells(4, pastefromendcolumn)).Copy
Worksheets("Pasted Results").Activate
Cells(pastetostartrow, 1).Select
Selection.PasteSpecial xlValues
Worksheets("Ranking Incl ZZ").Activate


Set pvtTable = Worksheets("Ranking Incl ZZ").PivotTables("PivotTable1")
Set pvtField = pvtTable.PivotFields("AA_name")

For iCount = 0 To 101

pvtField.CurrentPage = _
Worksheets("AAList").Range("AA_List").Offset(iCoun t, 0).Value

pastefromstartrow = 5
pastefromendrow = Cells(65536, 1).End(xlUp).Row

'SM add
'now the loop
For celltopaste = pastefromstartrow To pastefromendrow
'aa copy
Cells(1, 2).Copy Destination:=Worksheets("Pasted
Results").Cells(pastetostartrow + 1, 1)
'selecting the results of the pivottable (and the two ranking columns to the
right of it
Range(Cells(celltopaste, pastefromstartcolumn), Cells(celltopaste,
pastefromendcolumn)).Copy
Worksheets("Pasted Results").Activate
Cells(pastetostartrow + 1, 2).Select
Selection.PasteSpecial xlValues
Worksheets("Ranking Incl ZZ").Activate
'this variable will change after every paste
pastetostartrow = Worksheets("Pasted Results").Cells(65536, 1).End(xlUp).Row
Next celltopaste



Next iCount
Response = MsgBox("Task Complete")
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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM


All times are GMT +1. The time now is 08:33 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"