Target Address Property for Insert/Delete Row/Column

E

Excel Monkey

When I select call A1, the address property of the target is "$A$1". When I
select A1 and then hit Delete/Insert Rows/Column, the target is set to $1:$1.
However A1 is still selected visually (i.e. row 1 is not highlighted). I am
assuming that this is Excel's way of addressing where to insert/delete the
new range.

I need to find a way of referencing what the single cell address was prior
to excel changing it. Any ideas

Thanks

EM
 
E

Excel Monkey

Thanks.

EM

Per Jessen said:
Hi EM

I assume you are working with an event code. Declare a variable at the very
top of the worksheet module to remember LastTarget.

Dim LastTarget As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not LastTarget Is Nothing Then
MsgBox ("Current Target is " & Target.Address & vbLf & "Last Target was
" & LastTarget.Address)
End If
Set LastTarget = Target
End Sub

Hopes this helps

-Per
 

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