Hi! I was hoping someone might be able to tell me how to display the Edit Name dialog box from VBA for a specific existing name -- i.e. the dialog you would access manually via Formulas > Name Manager > [choose the name from the List Box] > Edit... .
The name in question is a LAMBDA function - let's call it
I've scoured this list of built-in
I did come up with this sub as a workaround:
This works well enough... but IMHO it's just not as elegant as showing the builtin Edit Name dialog. The layout is less familiar;
Any suggestions or solutions you can provide are welcome! Even if it's something hacky, or exceedingly complex, which uses a bunch of Windows APIs and such... I'm not afraid to get my hands dirty. I just kinda don't want to accept that answer seems to be "no; you can't do that"... I mean, isn't the joy of Excel that there is nothing you can't do if you really want to?
Thanks a bunch!
The name in question is a LAMBDA function - let's call it
MyFunction
- which appears in various places throughout the workbook. I want to show the Edit Name dialog for MyFunction
when my end user clicks a "Customize" button, to enable him/her to modify its functionality in an obvious way, without having to sift through all the other various names the workbook has in the Name Manager.I've scoured this list of built-in
Application.Dialogs
, as well as this list of arguments you can pass to the Show
method of a Dialog to see if maybe there was a way to do something like Application.Dialogs(xlNameManager).Show("MyFunction")
, or Application.Dialogs(xlNameManager).Show(ThisWorkbook.Names("MyFunction"))
... but to no avail.I did come up with this sub as a workaround:
VBA Code:
Sub EditMyFunction()
Dim vFormula As Variant
With ThisWorkbook.Names("MyFunction")
vFormula = Application.InputBox("Enter LAMBDA Expression:", "Edit Function", Default:=.RefersTo, Type:=0)
If vFormula = False Then Exit Sub
.RefersTo = vFormula
End With
End Sub
This works well enough... but IMHO it's just not as elegant as showing the builtin Edit Name dialog. The layout is less familiar;
Application.InputBox
has a "?" button in the Title bar which takes the user out to an irrelevant help page; and there is no space to leave/edit the Comment on MyFunction
. While a UserForm could address some of these issues, I'd rather not create a whole mimic UserForm.Any suggestions or solutions you can provide are welcome! Even if it's something hacky, or exceedingly complex, which uses a bunch of Windows APIs and such... I'm not afraid to get my hands dirty. I just kinda don't want to accept that answer seems to be "no; you can't do that"... I mean, isn't the joy of Excel that there is nothing you can't do if you really want to?
Thanks a bunch!