happyhungarian
Active Member
- Joined
- Jul 19, 2011
- Messages
- 252
- Office Version
- 365
- Platform
- Windows
Hi, I have two different change events I'd like to run on the same sheet. I'm having trouble having the second one run. Here's the first change:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C3")) Is Nothing Then Exit Sub
Application.CutCopyMode = False
ActiveWorkbook.RefreshAll
DoEvents
Sheets("Pivots").PivotTables("PivotTable1").PivotCache.Refresh
DoEvents
MsgBox "Queries Complete"
End Sub
And here's the second:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C5")) Is Nothing Then Exit Sub
Dim pt As PivotTable
Dim FieldContract_Date As PivotField
Dim NewContract_Date As String
Set pt = Worksheets("Pivots").PivotTables("PivotTable2")
Set FieldContract_Date = pt.PivotFields("Contract_Date")
NewContract_Date = Worksheets("Worksheet").Range("C5").Value
pt.RefreshTable
With pt
FieldContract_Date.ClearAllFilters
FieldContract_Date.CurrentPage = NewContract_Date
pt.RefreshTable
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C3")) Is Nothing Then Exit Sub
Application.CutCopyMode = False
ActiveWorkbook.RefreshAll
DoEvents
Sheets("Pivots").PivotTables("PivotTable1").PivotCache.Refresh
DoEvents
MsgBox "Queries Complete"
End Sub
And here's the second:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C5")) Is Nothing Then Exit Sub
Dim pt As PivotTable
Dim FieldContract_Date As PivotField
Dim NewContract_Date As String
Set pt = Worksheets("Pivots").PivotTables("PivotTable2")
Set FieldContract_Date = pt.PivotFields("Contract_Date")
NewContract_Date = Worksheets("Worksheet").Range("C5").Value
pt.RefreshTable
With pt
FieldContract_Date.ClearAllFilters
FieldContract_Date.CurrentPage = NewContract_Date
pt.RefreshTable
End With
End Sub