Sheet change event to return sheet name just left

  • Thread starter Thread starter Spike
  • Start date Start date
S

Spike

Does anyone have any idea how I can get the name of a worksheet that I have
just moved from. So if I am in Sheet1 and move to Sheet2, how do I get a
macro to return Sheet1. In all the Events I have looked at they all return
the name of the sheet that I have moved to not the sheet I have left.

Any help will be gratefully received
 
We need to remember it. In a standard module:

Public OldSheet As String
Public NewSheet As String

In the worksheet code area of every sheet:


Private Sub Worksheet_Activate()
If IsEmpty(OldSheet) Then
OldSheet = "x"
End If
MsgBox OldSheet
OldSheet = ActiveSheet.Name
End Sub
 
Back
Top