OnChange macro runs only partially

16 Views Asked by At

I am trying a worksheet onchange event, when cell "I4" is changed: empty cell "I9" and refresh a pivot table. Emptying the cell works, refreshing the pivot happens only after I click anywhere in the sheet and then click "I4" again. What is wrong with this?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Intersect(Target, Range("I4")) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    Range("I9").Value = ""
    ActiveSheet.PivotTables("ComplexFilter").PivotCache.Refresh
    Application.EnableEvents = True
End Sub
0

There are 0 best solutions below