Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default SheetSelectionChange Event find out previosly selected cell

Hello folks,

when the selection has changed in the grid the Event SheetSelectionChange is
thrown. Is there a possibility to tell what cell was previosly selected?


Thanks,


Anton


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 611
Default SheetSelectionChange Event find out previosly selected cell

Anton,

You can keep track of it yourself:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static OldCell As Range
If Not OldCell Is Nothing Then ' not first time
MsgBox "The old cell is " & OldCell.Address _
& "And it contained " & OldCell
End If

Set OldCell = Target
End Sub


Your code goes where the MsgBox line is. You use the OldCell object as a
range. It's the previous cell.
--
Earl Kiosterud
www.smokeylake.com

"Anton Sommer" wrote in message
...
Hello folks,

when the selection has changed in the grid the Event SheetSelectionChange
is thrown. Is there a possibility to tell what cell was previosly
selected?


Thanks,


Anton



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 611
Default SheetSelectionChange Event find out previosly selected cell

Anton,

It occurs to me that the old multiple-cell selection would confound this.
You might want to change the last line to:

Set OldCell = ActiveCell

Earl Kiosterud
www.smokeylake.com

"Earl Kiosterud" wrote in message
...
Anton,

You can keep track of it yourself:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static OldCell As Range
If Not OldCell Is Nothing Then ' not first time
MsgBox "The old cell is " & OldCell.Address _
& "And it contained " & OldCell
End If

Set OldCell = Target
End Sub


Your code goes where the MsgBox line is. You use the OldCell object as a
range. It's the previous cell.
--
Earl Kiosterud
www.smokeylake.com

"Anton Sommer" wrote in message
...
Hello folks,

when the selection has changed in the grid the Event SheetSelectionChange
is thrown. Is there a possibility to tell what cell was previosly
selected?


Thanks,


Anton





Reply
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
Event Macro - Hyperlink selected SteveT Excel Discussion (Misc queries) 0 June 19th 08 09:21 PM
Is there a way to call selected sheet's name from on deactivate event? Wandering Mage Excel Programming 3 July 9th 04 02:09 AM
SheetSelectionChange Frank Kabel Excel Programming 0 April 26th 04 04:28 PM
SheetSelectionChange Target size Limitation? Guillaume E. Excel Programming 1 September 27th 03 04:34 PM
VB code to find the selected cell Andrew[_22_] Excel Programming 2 September 9th 03 06:29 AM


All times are GMT +1. The time now is 09:45 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"