OnChange ?

I'm looking for the proper way to trigger a sub when the value in a cell changes. Any suggestions

Thanks

K-2



Answer this question

OnChange ?

  • Worf

    Hi K-2

    Try using the Worksheet change event, checking the target value to see if your cell is in the range that has been changed

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim myR As Range
    Dim Resp, c
    Set myR = Worksheets("Sheet1").Range("A3")
    For Each c In Target
    If c = myR Then
    Resp = MsgBox("A3 has been changed", vbOKOnly)
    End If
    Next

    End Sub


  • friggityfraggity

    ADG,

    I've tried this and it does not seem to run as a sub / macro. How do I use this

    Thanks,

    K-2


  • Nfrf

    The code is in a worksheet event. In the VBA project select the relevant sheet e.g. Sheet1, then select Worksheet in the first drop down box on the code window and then select Change in the second window. Then you can add yor code to this event.
  • OnChange ?