ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change event (https://www.excelbanter.com/excel-programming/315183-change-event.html)

Stefi

Change event
 
In a
Private Sub Worksheet_Change(ByVal Target As Range)
procedure the Target variables returns the cell just left only if it has
been changed. I need this cell's row number even if it has NOT been changed.
Is there any way?
Thanks Stefi

Frank Kabel

Change event
 
Hi
the nature of this event is that it is only triggered then a change occurs.
Maybe you could describe what you're trying to achieve with this information

"Stefi" wrote:

In a
Private Sub Worksheet_Change(ByVal Target As Range)
procedure the Target variables returns the cell just left only if it has
been changed. I need this cell's row number even if it has NOT been changed.
Is there any way?
Thanks Stefi


Tom Ogilvy

Change event
 
You would need to use the selectionchange event and store the value in a
static variable:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static OldTarget As Range
If Not OldTarget Is Nothing Then
MsgBox OldTarget.Row
End If
Set OldTarget = Target
End Sub

OldTarget would be the last cell selected. Depending on what you are doing,
you may need to make that variable public in the sheet module and initialize
with other events - because it will not be initialized on the first
selection by the user.

--
Regards,
Tom Ogilvy

"Stefi" wrote in message
...
In a
Private Sub Worksheet_Change(ByVal Target As Range)
procedure the Target variables returns the cell just left only if it has
been changed. I need this cell's row number even if it has NOT been

changed.
Is there any way?
Thanks Stefi





All times are GMT +1. The time now is 07:32 PM.

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