ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Last Selected Cell (https://www.excelbanter.com/excel-programming/364501-last-selected-cell.html)

DAV135

Last Selected Cell
 
Hi, I'm writing a macro which needs to run whenever a cell changes. To
do this I've set the macro to run on the Worksheet_Change function
which works perfectly. The problem I'm having is how to establish the
cell which was previously selected by the user before they either tab
or carriage return. ie. If the user is on cells A3 and enters "here",
I need to macro to tell me that the user changed row 3, column 1.

Any ideas?

Many Thanks!!


Tom Ogilvy

Last Selected Cell
 
Target holds a reference to the cell that was changed.

Private Sub Worksheet_Change(ByVal Target As Range)
msgbox Target.Address & " was changed and triggered this macro"
End Sub

--
Regards,
Tom Ogilvy


"DAV135" wrote:

Hi, I'm writing a macro which needs to run whenever a cell changes. To
do this I've set the macro to run on the Worksheet_Change function
which works perfectly. The problem I'm having is how to establish the
cell which was previously selected by the user before they either tab
or carriage return. ie. If the user is on cells A3 and enters "here",
I need to macro to tell me that the user changed row 3, column 1.

Any ideas?

Many Thanks!!



DAV135

Last Selected Cell
 
Fantastic! Thanks for your help!



All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com