Where was I before pressing enter/return or tab key

F

Fred

I am using Excel 2007

Is there a way to tell where I was (cell or row/column) before I
pressed the enter/return or used the tab key ?

I have a requirement to move a row of data from one sheet to another
if the status cell is changed to Green. I can get the correct row if
the value is selected from a validation list (using the
Worksheet_Change event), but if I type in the value and press enter/
tab key or click away using the mouse then the wrong row is selected.

Thanks for any suggestions
Fred
 
C

Clif McIrvin

Fred said:
I am using Excel 2007

Is there a way to tell where I was (cell or row/column) before I
pressed the enter/return or used the tab key ?

I have a requirement to move a row of data from one sheet to another
if the status cell is changed to Green. I can get the correct row if
the value is selected from a validation list (using the
Worksheet_Change event), but if I type in the value and press enter/
tab key or click away using the mouse then the wrong row is selected.

Thanks for any suggestions
Fred


Perhaps adding something like this to your Worksheet module will give
you what you need:

Option Explicit

Dim LastActiveSelection As Range
Dim SelectionBeforeLast As Range


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set SelectionBeforeLast = LastActiveSelection
Set LastActiveSelection = Target
End Sub

Then both of these variables would also be available to your
Worksheet_Change procedure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top