Tim_Excel_
Well-known Member
- Joined
- Jul 12, 2016
- Messages
- 512
Hi forum,
I have a Workbook_SheetChange event for another workbook (other than the workbook that holds the code). At the end of a lengthy Sub, I call for the Sub that defines the Workbook's name that the event needs to work for:
Then, in a Class Module sits the Workbook_Sheetchange event:
Problem is, the SheetChange event will only run if I manually run the DefineWorkbookName Sub myself first, even though the code is set to run (and does run) through this sub already.
Is there any way I could have the SheetChange event run without having to run the DefineWorkbookName sub manually first? Thanks a lot!
I have a Workbook_SheetChange event for another workbook (other than the workbook that holds the code). At the end of a lengthy Sub, I call for the Sub that defines the Workbook's name that the event needs to work for:
Code:
Sub step1()
'''''code''''
NameGrabber.DefineWorkbookName
End Sub
Code:
Dim oWb As New Updater
Sub DefineWorkbookName()
Application.EnableEvents = True
Dim AddNew As Workbook
Set AddNew = Workbooks("test1")
Set oWb.Workbook = AddNew
End Sub
Then, in a Class Module sits the Workbook_Sheetchange event:
Code:
Public WithEvents m_wb As Workbook
Public Property Set Workbook(wb As Workbook)
Set m_wb = wb
End Property
Public Property Get Workbook() As Workbook
Set Workbook = m_wb
End Property
Public Sub m_wb_SheetChange(ByVal Sh As Object, ByVal Target As Range)
''''code''''
End Sub
Problem is, the SheetChange event will only run if I manually run the DefineWorkbookName Sub myself first, even though the code is set to run (and does run) through this sub already.
Is there any way I could have the SheetChange event run without having to run the DefineWorkbookName sub manually first? Thanks a lot!