Change event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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.
 

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

Back
Top