Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PivotTables/VBA

Any VBA/Pivot table experts out there?


I have two identical workbooks, one old, one new. The
only difference between them is the data. In the old one
I can set up a pivot table using code - the new one gives
the error with exactly the same code:

'Unable to get the PivotFields property of the
PivotTable class'

The error occurs in the first row of the following code:

With ActiveSheet.PivotTables("PivotTable2").PivotFields
("Mode")
.Orientation = xlRowField
.Position = 1
End With

I can set up the pivot table in the new sheet manually
every time but when I try it with code it fails.

Help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PivotTables/VBA

It seems like your code is pointing to a range ("PivotTable2") that
doesn't exist in your new workbook.

The PivotTable names are automatically generated by Excel,
PivotTable1, PivotTable2, PivotTable3, etc. If this is the first
PivotTable in the new workbook, it's name might be PivotTable1,
therefore asking to pull a field in from PivotTable2 would be
impossible.

Check the name of the table, by right-clicking anywhere inside it and
viewing the "table options." If it's not named PivotTable2, then
replace your code with the new name and try to run it.

Hope that helps solve your issue...


"jngi" <jirwin@belfastinstitute wrote in message ...
Any VBA/Pivot table experts out there?


I have two identical workbooks, one old, one new. The
only difference between them is the data. In the old one
I can set up a pivot table using code - the new one gives
the error with exactly the same code:

'Unable to get the PivotFields property of the
PivotTable class'

The error occurs in the first row of the following code:

With ActiveSheet.PivotTables("PivotTable2").PivotFields
("Mode")
.Orientation = xlRowField
.Position = 1
End With

I can set up the pivot table in the new sheet manually
every time but when I try it with code it fails.

Help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default PivotTables/VBA

Thanks Jacinta

I forgot to mention that I have tried all sorts of
different names in the line to no avail.

Is there a way of using an index like (2) instead of a
name in quotes?

Thanks again

Jon
-----Original Message-----
It seems like your code is pointing to a range

("PivotTable2") that
doesn't exist in your new workbook.

The PivotTable names are automatically generated by Excel,
PivotTable1, PivotTable2, PivotTable3, etc. If this is

the first
PivotTable in the new workbook, it's name might be

PivotTable1,
therefore asking to pull a field in from PivotTable2

would be
impossible.

Check the name of the table, by right-clicking anywhere

inside it and
viewing the "table options." If it's not named

PivotTable2, then
replace your code with the new name and try to run it.

Hope that helps solve your issue...


"jngi" <jirwin@belfastinstitute wrote in message

...
Any VBA/Pivot table experts out there?


I have two identical workbooks, one old, one new. The
only difference between them is the data. In the old

one
I can set up a pivot table using code - the new one

gives
the error with exactly the same code:

'Unable to get the PivotFields property of the
PivotTable class'

The error occurs in the first row of the following code:

With ActiveSheet.PivotTables

("PivotTable2").PivotFields
("Mode")
.Orientation = xlRowField
.Position = 1
End With

I can set up the pivot table in the new sheet manually
every time but when I try it with code it fails.

Help!

.

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
Extracting from Pivottables John James Excel Discussion (Misc queries) 4 March 25th 06 01:13 AM
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


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

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

About Us

"It's about Microsoft Excel"