If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Macro to run when a particular cell is updated

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-13-07, 10:47
AdamS24 AdamS24 is offline
Registered User
 
Join Date: Feb 2006
Posts: 6
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 10:50.
Reply With Quote
  #2 (permalink)  
Old 03-13-07, 13:38
shades shades is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On