This might also work:
Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
Wn.Activesheet.Cells(Rows.Count, 2).End(xlUp).Offset(, 1).Value = Now
End Sub
I don't think you have to address the workbook and the sheet specifically since they are inherent in this event:
- Thisworkbook is equivalent to Workbook_ in the name of this eventcode
- WN is a window in thisworkbook
Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
msgbox Wn.parent.name
msgbox Wn.activesheet.name
End Sub