View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Ivey[_2_] Mark Ivey[_2_] is offline
external usenet poster
 
Posts: 171
Default Macro for returning to the previously selected cell

Not real sure if this will do what you want, but because Excel does not have
a "BeforeChange" event it can be somewhat complicated to do what you are
wanting to do.

Put the following inside "ThisWorkbook" and watch what happens as you move
from sheet to sheet with the Message Box prompts. Maybe something here will
work or maybe you can figure out what you need from here.

Sorry not to be of much help on this topic...

Mark Ivey

'**** Code Starts Here ****
Private wbOpenRange As Variant
Private shActivateRange As Variant
Private selChgRange As Variant

Private Sub Workbook_Open()
wbOpenRange = ActiveSheet.Name & "!" & ActiveCell.Address
test
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
shActivateRange = Sh.Name & "!" & ActiveCell.Address
test
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
selChgRange = Sh.Name & "!" & ActiveCell.Address
test
End Sub


Sub test()
If wbOpenRange = "" Then
wbOpenRange = "Nothing"
End If
If shActivateRange = "" Then
shActivateRange = "Nothing"
End If
If selChgRange = "" Then
selChgRange = "Nothing"
End If

MsgBox "ON OPEN EVENT: " & wbOpenRange & vbCrLf & vbCrLf _
& "SHEETACTIVEATE EVENT: " & shActivateRange & vbCrLf & vbCrLf _
& "SELECTIONCHANGE EVENT: " & selChgRange
End Sub