The following code resides in SubB which is called from SubA
When SubA is initiated due to CLICKING a button (forms control on worksheet) it runs smoothly.
When SubA is CALLED from a third Sub (SubX) it fails when trying to change the CodeName
It fails whether stepping through or running automatic. (Of course it ends all code, SubA 7 Sub X, not just SubB.)
Error:
Can’t enter into break mode at this time
ws.Copy After:=Sheet1
Set WsNew = ActiveSheet
With WsNew
.Name = "Cost " & Month(Date) & "-" & Day(Date) & "-" & Year(Date)
'these two separate rows required to change the CodeName
.Parent.VBProject.VBComponents(.CodeName) _
.Properties("_CodeName") = "CostDate"
End With
The reason I’m changing the codename is because regardless of what the user may do, I want to insure that this newly created CostDate sheet is ALWAYS DELTED prior to the creation of another.
It could be weeks later when the code is run and Sheet1 is copied again to make a new CostDate sheet
Bookmarks