Results 1 to 6 of 6

How to update Page field using result in another cell from drop down?

Threaded View

spmorin How to update Page field... 05-13-2008, 11:21 AM
davesexcel Hi, Please wrap your code... 05-13-2008, 11:31 AM
spmorin Sorry about not wrapping... 05-13-2008, 01:38 PM
davesexcel Where did you paste the... 05-13-2008, 04:39 PM
spmorin Thanks for the reply. This is... 05-14-2008, 05:38 AM
davesexcel Maybe worksheet_calculate... 05-14-2008, 06:38 AM
  1. #1
    Registered User
    Join Date
    05-13-2008
    Posts
    5

    How to update Page field using result in another cell from drop down?

    I am new to macros and VB with excel. I need to have a pivot tables page filed updated using a reference to another cell that is populated via a drop down.

    I have pulled several examples from the net, however i am unable to get them working.

    The one example I have is below. I have copied the code and replced all values, yet i still feel i am missing something?

    Please help.

    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 = "Calling Number"
    
    On Error Resume Next
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    
        If Target.Address = Range("C2").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
    Last edited by davesexcel; 05-13-2008 at 11:30 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1