I'm looking to call a subroutine based on the file name of the open workbooks. I have workbook A named "SubModel_OtherAdmin" where I am executing the subroutines and workbook B where I have the VBA logic(subroutines, functions, etc.) stored. I create a subroutine in workbook B called "Assumptions_OtherAdmin". Instead of using:
Call Assumptions_OtherAdmin
I would like to Call that particular subroutine based on the file name in workbook A. Big picture, Workbook A can be other workbooks such as "SubModel_Marketing" or "SubModel_Revenue", etc. Each of these will have their own Assumptions subroutine name built and stored in workbook B.
My initial thought was to define a String then use Call String
but that resulted in an error. My second thought was to build a table/grid in a tab in workbook B where the subroutines are stored that links the possible file names I will be working with to its respective Assumptions Subroutine name. For example, in column B row2 I would put the file name "SubModel_OtherAdmin" and in column C row2 I would put "Assumptions_OtherAdmin" and so on. I'm trying to brainstorm if I should create a function to Call the subroutine by finding the file name in column B and using the name in column C on the same row. I'm finding myself back to the same error as using Call String
as mentioned above. Another avenue I'm looking at is using select Case but I'm stuck in my planning process. Any thoughts or suggestions will be appreciated.