ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to retrieve the last selected cell before SelectionChange even (https://www.excelbanter.com/excel-programming/411753-how-retrieve-last-selected-cell-before-selectionchange-even.html)

Frank Krogh[_3_]

How to retrieve the last selected cell before SelectionChange even
 
I am using the SelectionChange event like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target(1, 1), Range("m1:m1")) Is Nothing Then Exit Sub
....
End Sub

My question is if it's a way to retrieve which cell was selected before the
M1 cell is selected?

Regards

Frank Krogh

Per Jessen

How to retrieve the last selected cell before SelectionChange even
 
Hi Frank

Here's a way to do it:

Dim LastSelected As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target(1, 1), Range("m1:m1")) Is Nothing Then GoTo XIT
MsgBox LastSelected
'...
XIT:
LastSelected = Target.Address
End Sub

Regards,
Per

"Frank Krogh" skrev i meddelelsen
...
I am using the SelectionChange event like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target(1, 1), Range("m1:m1")) Is Nothing Then Exit Sub
...
End Sub

My question is if it's a way to retrieve which cell was selected before
the
M1 cell is selected?

Regards

Frank Krogh



Frank Krogh[_3_]

How to retrieve the last selected cell before SelectionChange
 
Thank you for the solution.

Frank

"Per Jessen" wrote:

Hi Frank

Here's a way to do it:

Dim LastSelected As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target(1, 1), Range("m1:m1")) Is Nothing Then GoTo XIT
MsgBox LastSelected
'...
XIT:
LastSelected = Target.Address
End Sub

Regards,
Per

"Frank Krogh" skrev i meddelelsen
...
I am using the SelectionChange event like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target(1, 1), Range("m1:m1")) Is Nothing Then Exit Sub
...
End Sub

My question is if it's a way to retrieve which cell was selected before
the
M1 cell is selected?

Regards

Frank Krogh





All times are GMT +1. The time now is 10:58 AM.

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