Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    6

    Unanswered: Macro to run when a particular cell is updated

    Hi,

    I have been looking for a way to have a macro run when a particular cell is updated. (example: after a cell has been typed in and [enter] pressed it now automatically shifts focus to another work sheet.)

    I have looked through the list of events that excel can run macros off, but cant find one that corresponds to the update of one particular cell.

    The closest event I have found is for a update to a worksheet:
    (Specific code is run for a change to cell C4 in the code below)

    Private Sub Worksheet_Change(ByVal Target as Range)
    If ActiveCell.Address = "$C$4" Then
    MsgBox (ActiveCell.Address & "Is active")
    End If
    End Sub

    (Only problem with this event is that it might make the spreadsheet slower because it runs for all updates/changes made)

    Thanks for any help.
    Last edited by AdamS24; 03-13-07 at 11:50.

  2. #2
    Join Date
    Oct 2003
    Posts
    1,091
    Howdy. You have chosen the correct event. Just include an intersection between Target and your specific cell. For example, assume your cell is P2, then you could use something like this.

    Code:
        Dim rng As Range
        ' Target is a range::therefore,it can be more than one cell
        Set rng = Intersect(Target, Range("P2"))
    old, slow, and confused
    but at least I'm inconsistent!

    Rich
    (retired Excel 2003 user, 3/28/2008)

    How to ask a question on forums

Posting Permissions

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