![]() |
Responding to cell events in Excel
Angus,
Use the SelectionChange event procedure. Put the following code in the code module for the appropriate worksheet. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static PrevRange As Range If Not PrevRange Is Nothing Then MsgBox "PrevRange: " & PrevRange.Address & vbCrLf & _ "Current Range: " & Target.Address End If Set PrevRange = Target End Sub PrevRange will refer to the cell that was selected before changing the selection, and Target will refer to the currently selected range. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Angus Comber" wrote in message ... Hello I want to do the following: A) When I move away from a cell - ie by tabbing or moving with mouse - I want to be able to check the contents of the previously selected cell. B) When I move away from a cell - as above - I want to be able to check the contents of the cell moved to. So I need a BeforeMoveAway event and a JustMovedToCell event or similar. Can anyone help because I am finding this tricky Angus Comber |
All times are GMT +1. The time now is 11:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com