I have a series of Subroutines that are all similarly named but different enough that they need to be treated distinctly. There is a dropdown menu on a named range called LeadOption which has 5 possible selections (numbers 1-5), and depending on which option is chosen I want a particular Sub to run as part of a larger macro.
For example if LeadOption is 1, then I want the Sub Example_1 to run. If LeadOption is 2 then Example_2, and so on. I tried the code:
But this breaks before running, with the error Compile Error: Expected Sub, Function or Property. Ideally I don't want to have to write out a load of IF statements, as I will have to do this for another 20+ LeadOption style named ranges that are doing similar things - is there a way to use a String to selectively call a Sub which is dependent on an input like this?
For example if LeadOption is 1, then I want the Sub Example_1 to run. If LeadOption is 2 then Example_2, and so on. I tried the code:
VBA Code:
Dim SubOption as String
SubOption = "Example_" & Range("LeadOption").value
Call SubOption
But this breaks before running, with the error Compile Error: Expected Sub, Function or Property. Ideally I don't want to have to write out a load of IF statements, as I will have to do this for another 20+ LeadOption style named ranges that are doing similar things - is there a way to use a String to selectively call a Sub which is dependent on an input like this?