View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default Last Cell Accessed

use the CHANGE event for the sheet....right click the tab and select the code
page. This is the sheet's code page....then you can code the proc below,
where Target is the cell hat has changed. Caution....if the procedure changes
the value of any cell, then it will call itself...thats ok if the resultant
call doesn't make any more changes. If it does, then you'll set off a
recursive loop....so set Application.EnableEvents = False to turn off event
handling first!.
Example:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
' test for a given range, where the values must be 1< 10
If Not Intersect(Range("InputArea"), Target) Is Nothing Then
Application.EnableEvents = False
Select Case Target.Value

Case Is < 1
Target.Value = 1
Case Is 10
Target.Value = 10
End Select
Application.EnableEvents = True
End If
End Sub


"Andrew" wrote:

Hi,

I want to capture the last cell data was entered so I can validate it and
return the cursor there if required. The user can 'Enter' or 'Arrow' away.

Any ideas?
--
Andrew