Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://www.mrexcel.com/board/threads/make-sheetselectionchange-operate-on-a-different-workbook.888122/

ThisWorkbook:

Option Explicit
Dim xlApp As New XL_SheetSelectionChange
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Set xlApp.XL = Nothing
End Sub
Private Sub Workbook_Open()
 Set xlApp.XL = Application
End Sub

Class Module:

Option Explicit

Public WithEvents XL As Application

Private Sub XL_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Debug.Print Sh.Parent.Name & ", " & Sh.Name & ", " & Target.Address
End Sub

  • No labels