Adding a Name Crashes Excel
Hi! Whenever I call the "ActiveWorkbook.Names.Add" function, Excel
will simply panic, and quit altogether. This happens no matter what
the worksheet the name is directed to, or what the name or range
actually is (or if it already exists). The same goes for trying to
delete names.
However, this only happens when I run it from a worksheet function. If
I simply call it from the VBA editor, it works without issue.
Here is some example code that crashes things --
Public Function myStarNight(lookupStr As Variant) As String
Debug.Assert False
Dim hat As Variant
Set hat = ActiveWorkbook.Names.Add("Hi", "A1:A5")
Let myStarNight = "Hi!"
End Function
I insert this into a worksheet, and when I do that, the code simply
exits with no result. However, if I call it directly from VBA, it
works fine. Any insight?
|