+ Reply to Thread
Results 1 to 3 of 3

Combine two Worksheet_Change macros

  1. #1
    Registered User
    Join Date
    09-28-2011
    Location
    new zealand
    MS-Off Ver
    Excel 2003
    Posts
    4

    Combine two Worksheet_Change macros

    Hi

    This is the VBA code I have (which I found here http://stackoverflow.com/questions/1...ue-into-a-cell) to filter a pivot table based on the value of a cell using data validation.

    Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    Set rng = Me.Range("MonthSelect")
    If Not Application.Intersect(Target, rng) Is Nothing Then
    With Sheets("Dashboard").PivotTables("PivotTable1").PivotFields("Month")
    .ClearAllFilters
    If Len(rng.Value) > 0 Then .CurrentPage = rng.Value
    End With
    End If
    End Sub


    What I want to be able to do is combine it with the below so I can filter by two different criteria.

    Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    Set rng = Me.Range("ContractSelect")
    If Not Application.Intersect(Target, rng) Is Nothing Then
    With Sheets("Dashboard").PivotTables("PivotTable1").PivotFields("Contract")
    .ClearAllFilters
    If Len(rng.Value) > 0 Then .CurrentPage = rng.Value
    End With
    End If
    End Sub


    Any help would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Combine two Worksheet_Change macros

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-28-2011
    Location
    new zealand
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combine two Worksheet_Change macros

    Hi yudlugar

    It works perfectly, thanks for your time it's very much appreciated

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combine 2 worksheet_change event macros
    By RebelVampire in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2013, 12:37 AM
  2. Combine Private Sub Worksheet_Change VBA Code on same worksheet
    By stanlelma in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2013, 12:42 PM
  3. [SOLVED] How to Combine 3 instances of Worksheet_Change(ByVal Target As Range)
    By Grumpygrandad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2013, 11:12 PM
  4. Using Worksheet_Change to initiate Macros
    By Jimbo42 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2013, 07:30 PM
  5. How to combine two Worksheet_Change subs into one?
    By zozo23 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-26-2012, 09:07 PM

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