Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KtM KtM is offline
external usenet poster
 
Posts: 13
Default Dynamic pivottables

Hi!
Can anyone find whats wrong with the following VBA, I cant seem to find
why

"With ActiveSheet.PivotTables(apuFirma & "Pivot").PivotFields("Stage")
.Orientation = xlDataField
.Caption = "Average of Stage"
.Function = xlAverage"
stops all the time.
The whole code part(relevant) is below.

Sheets(apuFirma & "Q" & qCount).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=
_
"'" & apuFirma & "Q" & qCount & "'!A:B").CreatePivotTable
TableDestination:="", TableName:= _
"'" & apuNimi & "Pivot" & "',
DefaultVersion:=xlPivotTableVersion10"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3,
1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables(apuFirma &
"Pivot").PivotFields("Stage")
.Orientation = xlDataField
.Caption = "Average of Stage"
.Function = xlAverage
End With
ActiveSheet.PivotTables(apuNimi & "Pivot").AddDataField
ActiveSheet.PivotTables( _
apuFirma & "Pivot").PivotFields("Stage"), "Count of Stage",
xlCount
Range("A3").Select
ActiveSheet.PivotTables(apuNimi & "Pivot").PivotFields("Count of
Stage").Function _
= xlAverage

Any ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Dynamic pivottables

what is the error message?

"KtM" wrote:

Hi!
Can anyone find whats wrong with the following VBA, I cant seem to find
why

"With ActiveSheet.PivotTables(apuFirma & "Pivot").PivotFields("Stage")
.Orientation = xlDataField
.Caption = "Average of Stage"
.Function = xlAverage"
stops all the time.
The whole code part(relevant) is below.

Sheets(apuFirma & "Q" & qCount).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=
_
"'" & apuFirma & "Q" & qCount & "'!A:B").CreatePivotTable
TableDestination:="", TableName:= _
"'" & apuNimi & "Pivot" & "',
DefaultVersion:=xlPivotTableVersion10"
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3,
1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables(apuFirma &
"Pivot").PivotFields("Stage")
.Orientation = xlDataField
.Caption = "Average of Stage"
.Function = xlAverage
End With
ActiveSheet.PivotTables(apuNimi & "Pivot").AddDataField
ActiveSheet.PivotTables( _
apuFirma & "Pivot").PivotFields("Stage"), "Count of Stage",
xlCount
Range("A3").Select
ActiveSheet.PivotTables(apuNimi & "Pivot").PivotFields("Count of
Stage").Function _
= xlAverage

Any ideas?


  #3   Report Post  
Posted to microsoft.public.excel.programming
KtM KtM is offline
external usenet poster
 
Posts: 13
Default Dynamic pivottables

Run-Time error '1004':
Unable to get the Pivottables property of the Worksheet class.

I am not so familiar with the pivottables property, but I cant figure
easier way to get subtotal averages of 2 rows, so Im shooting in the
dark with it. (Macroed it and made it "dynamic".

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Dynamic pivottables

check the name of the Pivottable !

apuFirma & "Pivot"

this cannot be found in the pivottables on that sheet

HTH

Philip

"KtM" wrote:

Run-Time error '1004':
Unable to get the Pivottables property of the Worksheet class.

I am not so familiar with the pivottables property, but I cant figure
easier way to get subtotal averages of 2 rows, so Im shooting in the
dark with it. (Macroed it and made it "dynamic".


  #5   Report Post  
Posted to microsoft.public.excel.programming
KtM KtM is offline
external usenet poster
 
Posts: 13
Default Dynamic pivottables

Thanks, had one count of apuNimi as apuFirma(apu=help in finnish, just
temporary collections to reduce certain operations).

How can you see the pivottables of the sheet? I have not really used
pivottables much, just basic reporting type drag'n'drop pivottable
usage.

I fixed the names, so they should be OK. now(from "'" & apuNimi &
"Pivot" & "' to aPufirma, so it should now be named as supposed, unless
that "'" thingie messes it up?)

I am at a loss what to check with this one.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Dynamic pivottables

try some code like this:

dim xPTable as pivottable

for each xPTable in activesheet.pivottables
debug.print xPTable.name
next

HTH

Philip

"KtM" wrote:

Thanks, had one count of apuNimi as apuFirma(apu=help in finnish, just
temporary collections to reduce certain operations).

How can you see the pivottables of the sheet? I have not really used
pivottables much, just basic reporting type drag'n'drop pivottable
usage.

I fixed the names, so they should be OK. now(from "'" & apuNimi &
"Pivot" & "' to aPufirma, so it should now be named as supposed, unless
that "'" thingie messes it up?)

I am at a loss what to check with this one.


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
PivotTables Gerry Verschuuren Excel Discussion (Misc queries) 4 October 25th 07 01:12 AM
PivotTables KerryK Excel Discussion (Misc queries) 2 October 8th 07 07:06 PM
New to Pivottables- need help coal_miner Charts and Charting in Excel 1 June 6th 05 06:48 PM
Drill Down in PivotTables doco Excel Discussion (Misc queries) 2 February 3rd 05 11:46 PM
PivotTables/VBA jngi[_3_] Excel Programming 2 September 24th 04 12:27 PM


All times are GMT +1. The time now is 10:23 PM.

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"