ubermensch
New Member
- Joined
- Jun 24, 2011
- Messages
- 6
I recently had to replace my hard drive and in the process I ended up going from Excel 2010 to Excel 2007. The script has been working fine previously but now it has stopped. I have checked the Trust Centre settings to make sure macros will run. I have also checked ?Application.EnableEvents and that returns "true". Any tips on what other things I can check would be appreciated.
Code:
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 = "Account 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
EnableMultiplePageItems = False
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
Call multiFindandReplace
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub