none
How to get notify when user is try to write in a cell? RRS feed

  • Question

  • Hi ,

    What is the event that invoke when user try to write on a cell, and how to use that, can we get old and new value both for that cell?

    Please also show the example how to use it?

    Thanks in advance

    Thanks

    Ankur Rastogi

    Friday, March 10, 2017 7:07 AM

All replies

  • Hello,

    I think you may handle Worksheet.Change Event (Excel): Occurs when cells on the worksheet are changed by the user or by an external link.

    We could get new value for that cell using Worksheet.Change

    E.g.

    Private Sub Worksheet_Change(ByVal Target As Range)
    MsgBox Target.Value
    End Sub

    If you want to get old value, I would suggest you use Worksheet.SelectionChange Event (Excel).

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 13, 2017 2:35 AM
    Moderator
  • Colud you please provide me complete example? 

    Thanks

    Ankur  R.

    Wednesday, March 15, 2017 6:53 AM
  • Hello,

    The code below is a sample to use message box to show value.

    Private Sub Worksheet_Change(ByVal Target As Range)
    MsgBox Target.Value
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    MsgBox Target.Value
    End Sub
    

    Please see:

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 16, 2017 10:48 AM
    Moderator