Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2006, 02:47 AM
Registered User
 
Join Date: Jul 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Run time error using Orientation for PivotField

I've a pivot table where i need to hidden several fields (data fields) in a vba program. Using the macro registration technique i saw that the property used was like that:

    ActiveSheet.PivotTables("Pivot_table1").PivotField s("Name").Orientation = xlHidden

Then i inserted the code automatically created into my code and i had a strange result: for the data fields coming out from the data source the Orientation property was working, for a calculated filed i receive back the 1004 run time error (the translation message from the italian version is roughly "impossible to set the property Orientation for the PivotField class".

The question is: how can i hidden a calculated field?


Mario
 
Old June 24th, 2009, 10:06 AM
Registered User
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hide Pivot Table Calculated Field

I've been having this same problem in Excel 2003. I'm trying to hide a calculated field "BGT Var", and I get an error that states "Unable to set the Orientation property of the PivotField class. Does anyone have any idea how to hide a calculated field with VBA? Below is the code.

Code:
 
Sub Fin_Amt_Class_Select()
 
'On Error Resume Next
Dim pt As PivotTable
Dim ws As Worksheet
Set ws = Worksheets("Proj_Summ")
Set pt = ws.PivotTables("PivotTable1")
 
pt.PivotFields("Re-FCST").Orientation = xlHidden
 
End Sub
 
Old June 24th, 2009, 10:09 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Can you try

pt.PivotFields("Re-FCST").Hidden = True

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
run time error ashishroyk Java GUI 0 October 8th, 2004 01:42 AM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM
RUN-TIME ERROR compcad Beginning VB 6 2 May 21st, 2004 02:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.