Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Code to link Pivot page fields to DV Lists


I know this is pretty easy, but i'm kind of new to VBA



I have found this code in Debra Dalgleish Site.

It's about linking Pivot table page field to a cell dropdown list.

I need it modified to do multiple page fields...

Codes between $$ $$ are my attempt.



Private Sub Worksheet_Change(ByVal Target As Range)

Dim ws As Worksheet
Dim pt As PivotTable
Dim pi As PivotItem
Dim strField As String

strField = "Country"
$$ strField = "Location" $$
$$ strField = "Product" $$

or

$$ strField = ("Country","Location","Product") $$

or

$$ strField = MyRange (I have created a name range for B2:B4) $$



On Error Resume Next
Application.EnableEvents = False
Application.ScreenUpdating = False

If Target.Address = Range("B2").Address Then
$$ If Target.Address = Range("B2:B4").Address Then $$
For Each ws In ThisWorkbook.Worksheets
For Each pt In ws.PivotTables
With pt.PageFields(strField)
For Each pi In .PivotItems
If pi.Value = Target.Value Then
.CurrentPage = Target.Value
Exit For
Else
.CurrentPage = "(All)"
End If
Next pi
End With
Next pt
Next ws

End If

Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub

*******************

I also tried to use the same code 3 times (changing the variables to
something like ws2, ws3...) but didn't work either... not sure if it's
because the worksheet change event is private or...



Thanks.


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
Pivot page fields! Sharon Excel Programming 7 June 4th 08 09:31 PM
Conditional Linking and Formatting across worksheets to form Summary Page - Only pull/link non-null fields J Leckner Excel Worksheet Functions 1 September 22nd 06 04:18 PM
Pivot Table Page fields Ajit Excel Discussion (Misc queries) 1 October 12th 05 05:49 PM
Pivot Table page fields Chad W. Excel Discussion (Misc queries) 1 July 27th 05 04:27 PM
Pivot Table Page Fields Andy Excel Discussion (Misc queries) 1 December 17th 04 05:25 PM


All times are GMT +1. The time now is 12:08 PM.

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"