So I have an excel add-in that, amongst other things, contains a huge list of aliases. For example, Country names with their ISO codes, Countries with their continents, etc etc (so that I can easily know that Canada is in America or that Côte D'Ivoire's national language is French, etc). Currently, I have the xlam with all the relevant functions that check named ranges in another workbook.
So summarizing, I have 2 files:
- macros.xls (has all the named ranges with things like Angola = AGO, etc), and
my_functions.xlam (has the functions that I can call from excel to get the Alias name). An example function is:
Function nti(v) nti = WorksheetFunction.VLookup(Trim(v), Range("macros.xls!nti"), 2, 0) End Function
Where nti is the function that I use and macros.xls!nti is the named range that I am referencing.
This all works great, but that means that this functionality requires two files, since an .xlam file can not be opened and edited in excel, only in VBA explorer.
Question: How can I have an easily modifiable lists and functions referring to these lists in one file? The functions should be available to other files I'm working on.
Disqualified solutions:
- Save the my_functions.xlam as an .xls temporarily, copy all the named ranges in, and then save it back as an .xlam. This would be annoying to do every time I want to make a change to the named ranges (which is fairly frequent).
- Hardcode a bunch of 2 column arrays with all the aliases into each function (thousands of lines long sometimes). PLEASE tell me there's a sexier way...
Thanks in advance!