View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Run Macro on cell exit

One way:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static rOldCell As Range
If Not rOldCell Is Nothing Then
If Not Intersect(rOldCell, Range("A1")) Is Nothing Then
'your code here
End If
End If
Set rOldCell = Target
End Sub


In article ,
"Kelly" wrote:

Hi group I am using the Office 2000 package

I am looking ofr a way to run a macro on the exit of a
cell.


Example I want to run the code each time the target leaves
A1


I know you can run a macro each time there is a change of
cell address that is not equal to A1 by using

"Worksheet_SelectionChange"

If Target.Address < A1 Then

Bla Bla Bla

But I would prefer to not run this entire code each time
the cell target changes. Just when it leaves A1

One idea I had was to have part of a code run each time
the address was equal to A1 then just hold until the
address was not equal to A1 and then run. I am not sure
how to do this though.

Make sense? Other ideas?

Kelly