@gravanoc, glad your problem has been resolved.
@Gokhan Aycan, pretty nice workaround, although I prefer to use as few ActiveX elements as possible on my worksheets. Nevertheless, I will definitely be able to use this one day
Is using the Debug menu's Compile different from the Compile on Demand option?
Compile VBAProject from the menu compiles the entire project, the on demand option compiles as needed during run-time. The latter option dates back to a time when computers could be relatively slow. Enabling this option could potentially increase performance a bit back then, with today's computers that doesn't have any noticeable impact. Excel has evolved quite a bit since then, the VBE on the other hand, barely.
Consider the code below, within different modules (with some absolutely unintentional typos
). With Compile on Demond option enabled and not performing a Compile VBAProject, running ProgramEntry results in a compile error when entering the FigureThisOut procedure, meanwhile without any warning giving us 0 where 16 was expected, caused by the lack of the Option Explicit statement. So the final program flow, usually depending on the interaction with the user, determines if and when the compiler errors out, which should make a coder quite uncomfortable.
Regarding your additional issue, provided optSht and newRng are valid objects it should work. Hard to tell what's causing it without seeing the code involved and the contents of the names collection.
Module1
VBA Code:
Public Sub ProgramEntry()
MsgBox Square(4)
FigureThisOut "OnceMore"
End Sub
Public Sub CallMe()
End Sub
Module2
VBA Code:
Public Function Square(ByVal argNumber As Long) As Long
Squared = argNumber ^ 2
End Function
Public Sub FigureThisOut(ByVal argTxt As String)
Ca11Me
End Sub