LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Find cell address of previous active cell

This method works on the second and subsequent cursor movement but
obviously not on the first cursor movement since prevTarget and
currTarget are initially null. Any ideas on how to capture the
previous active cell on the first cursor movement?

Mike Woodhouse wrote:
I can only think of tracking SelectionChange events. Try putting this
in your worksheet's Module:

Option Explicit
Dim prevTarget As Range
Dim currTarget As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next ' Lazy workaround for empty objects first time through
Set prevTarget = currTarget
Set currTarget = Target
Debug.Print "Now at " & currTarget.Address & ", previously at " & prevTarget.Address
On Error GoTo 0
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find address of active cell Dave Excel Worksheet Functions 5 September 6th 06 06:43 PM
how to compare the active cell value to the previous cell's value crimsonkng Excel Programming 2 December 5th 05 03:19 PM
Previous active cell MVM Excel Programming 3 January 2nd 05 10:29 PM
How do I reference the cell address next to Active cell - Try 2 Nico Le Roux Excel Programming 3 February 19th 04 06:04 AM
How do I reference the cell address next to Active cell Nico Le Roux Excel Programming 5 February 17th 04 07:45 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"