Private Sub Worksheet_Change(ByVal Target As Range)
End Sub
You can put in here whatever it is that you want to happen. Target is a range object and will hold a reference to the range which was changed. You need to add a check to see if the changed cell was F19 and, if it was, perform the appropriate changes.
[pre][code]Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$F$19" Then
'do some stuff
End If
End Sub
When it comes to the changes you want to make, you have to be very careful. If the change you want to make is to update a cell then you have a problem. That's because changing a cell causes the Worksheet_Change() event handler to be called again, so you could find yourself in a situation where code in the event handler is causing it to call itself: not very desirable! To prevent this, you can temporarily disable application events by using the Application.EnableEvents property. However, you again have to be careful: you must be certain to re-enable events at the end of the procedure otherwise it won't be called again when a change on the worksheet is made. To guarantee that Application.EnableEvents is set back to True you really have to include some error handling, so your starting point is this:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
If Target.Address = "$F$19" Then
'if we want to change a cell then we must set
'application.enableevents to false to prevent recursion
Application.EnableEvents = False
Range("B21").FormulaR1C1 = "=""%""&R[-2]C[4]&""%"""
PivotTables("PivotTable3").PivotCache.Refresh
End If
ErrorExit:
On Error Resume Next
Application.EnableEvents = True
Exit Sub
ErrorHandler:
MsgBox CStr(Err.Number) & vbNewLine & Err.Description
Resume ErrorExit
End Sub