vba workbook_sheetchange event for xlam thisworkbook. RRS feed

  • Question

  • Hi, Is there any way to write "workbook_sheetchange" event for Addin xlam Modules or thisworkbook. Appriciate if you can provide a solution.

    Thanks, Divakar.


    Monday, October 22, 2012 10:59 AM

All replies

  • You can try with:

    In calass module:

    Public WithEvents AppEvents As Application Private Sub AppEvents_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) Debug.Print Sh.Parent.Name & "|" & Sh.Name & "|" & Target.Address End Sub

    Private Sub AppEvents_WorkbookActivate(ByVal Wb As Workbook)
        Debug.Print Wb.Name & "|" & Wb.ActiveSheet.Name 
    End Sub

    in module and start in workbook_open or open form ...

    Sub Init()
      Set AppObject.AppEvents = Application
    End Sub
    Sub Term()
      Set AppObject.AppEvents = Nothing
    End Sub

    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

    Monday, October 22, 2012 11:35 AM
  • I can't get to put the code into my modules and classes, Can U pls help me to where I can put this code in my project and see my Project attached in the image below.


    Monday, October 22, 2012 12:11 PM