rjacmuto32
Member
I have this simple code below. It's using the worksheet change function and everytime the value in D2 is changed, then the pivot table gets updated and then I want to select a cell on another sheet. The code works great in the begining but the error is when I try to select Sheet2 then Range B1, i get a error o Debug. It can't select Cell B2. Anyone know why this is happening or how to fix it. It's a simple code.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$2" Then
Worksheets("Sheet1").PivotTables("PivotTable1").PivotCache.Refresh
End If
Sheets("Sheet2").Select
Range("B1").Select
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$2" Then
Worksheets("Sheet1").PivotTables("PivotTable1").PivotCache.Refresh
End If
Sheets("Sheet2").Select
Range("B1").Select
End Sub