Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Jacksonville, Florida, USA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Execute on Cell Value Change (Excel 2000)

    I would like a macro to run every time I change the contents of a cell. i.e. Cell B4 has the value of "2" in it. When I enter "3" (or any other value) into the cell, macro "do_something" runs.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Execute on Cell Value Change (Excel 2000)

    You do this by creating a Worksheet_Change event handler:
    - Activate the Visual Basic Editor (Alt+F11)
    - Make sure that the Project Explorer is visible (Ctrl+R)
    - Double click the node corresponding to the worksheet containing the cell you want to monitor.
    - Write or copy/paste code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B4")) Is Nothing Then
    do_something
    End If
    End Sub

    If your code manipulates cell contents, you may want to prevent other events from being processed temporarily:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B4")) Is Nothing Then
    Application.EnableEvents = False
    do_something
    Application.EnableEvents = True
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •