Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

VBA and Pivot Tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stu-Pid - 25 Jan 2006 12:33 GMT
Hi all, first post so please be gentle!  :)

I'm currently putting together a VBA Macro to allow less Excel minded
people to use a complex pivot table.  I am able to get the macro to run
as I want it to, except I cannot find the right way to allow the user to
enter variables on a front sheet that will then be picked up by the
macro and then the right pivot table function selected.  I currently
have:

Range("A8").Select
With ActiveSheet.PivotTables("PivotTable2").CubeFields("[DATE]")
.Orientation = xlPageField
.Position = 1
End With

ActiveSheet.PivotTables("PivotTable2").PivotFields("[DATE]").CurrentPageName
= _
"[DATE].[All DATE].[2006].[January]"
Columns("A:A").ColumnWidth = 18.71
With
ActiveSheet.PivotTables("PivotTable2").CubeFields("[ACCESS_CAMPAIGN]")
.Orientation = xlPageField
.Position = 2
End With

ActiveSheet.PivotTables("PivotTable2").PivotFields("[ACCESS_CAMPAIGN]").
_
CurrentPageName = "[ACCESS_CAMPAIGN].[All
ACCESS_CAMPAIGN].[0844]"

etc etc etc

However, where it selects [0844] above, I would like this to select
whatever value is shown in cell C3 of the worksheet called 'Inputs'
instead.

Is this possible?

Thanks in advance

Stu

Signature

Stu-Pid

Tom Ogilvy - 25 Jan 2006 14:11 GMT
Possibly

s = worksheets("Inputs").Range("C3").Value
CurrentPageName =  _
 "[ACCESS_CAMPAIGN].[All ACCESS_CAMPAIGN].[" _
   & s & "]"

Signature

Regards,
Tom Ogilvy

> Hi all, first post so please be gentle!  :)
>
[quoted text clipped - 10 lines]
> Position = 1
> End With

ActiveSheet.PivotTables("PivotTable2").PivotFields("[DATE]").CurrentPageName
> = _
> "[DATE].[All DATE].[2006].[January]"
[quoted text clipped - 21 lines]
>
> Stu
Stu-Pid - 25 Jan 2006 17:44 GMT
Thanks for the reply.

It seems to work perfectly, many thanks! :

--
Stu-Pi
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.