lkpederson
06-11-2015, 03:40 PM
I have a subroutine with an string array of names. I'd like to use those as the names of functions to call i.e. loop through a string array until you get a match then execute the function. Additionally, the functions need to pass a string array to be able to do their work.
Note: One of Fnc(x) will have commonality with one or more of the arr1. The left 3-6? characters will be the same.
Pseudocode:
Sub GoDoStuff()
Dim Fnc(2) As String, arr1() As String, Result() As String
' array of names for functions
Fnc(0) = "A"
Fnc(1) = "B"
Fnc(2) = "C"
do stuff and create an array, arr1, by searching through some data.
' call the function by Fcn(x)
If arr1 Like Fnc(i) Then
Application.Run Fnc(i), arr1(), Result() <-- tried this
Application.Run "Fnc(i), arr1(), Result() <-- and this
Application.Run (Fnc(i), arr1(), Results()) <-- and this
Ideas? I can post the actual code as well but may be adequate. Perhaps it's not possible.
I know I can achieve what I want by writing "If Thens" and calling each function but wanted to see if there was a cleaner way.
Note: One of Fnc(x) will have commonality with one or more of the arr1. The left 3-6? characters will be the same.
Pseudocode:
Sub GoDoStuff()
Dim Fnc(2) As String, arr1() As String, Result() As String
' array of names for functions
Fnc(0) = "A"
Fnc(1) = "B"
Fnc(2) = "C"
do stuff and create an array, arr1, by searching through some data.
' call the function by Fcn(x)
If arr1 Like Fnc(i) Then
Application.Run Fnc(i), arr1(), Result() <-- tried this
Application.Run "Fnc(i), arr1(), Result() <-- and this
Application.Run (Fnc(i), arr1(), Results()) <-- and this
Ideas? I can post the actual code as well but may be adequate. Perhaps it's not possible.
I know I can achieve what I want by writing "If Thens" and calling each function but wanted to see if there was a cleaner way.