Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm working in VBA (in excel specifically). I need to pull data out of poorly formatted text files. I have my search functions working, but am trying to streamline the code (remove redundancy).

Specifically I want to hand a function to run when a successful search is caried out, Sudo Code Example:
VB
Private Function magicSearchFunction(searchString As String, functionToRun As String)

'Magic search done here

If Successful
	'Run specific function that was handed in "functionToRun"
End If

End Function


I usually don't work in VB so sorry if this is a newb question. I know I can do this in C# (like this "{0}, stuffToDo")

Alternatively I will need to have a copy of my search functions for each search that needs to perform different tasks in the "If Successful" area, which jsut seems like poor programming technique.

Thanks in advance for any help you can offer!
Posted

1 solution

You can use the Application.Run method. See here for an example, http://stackoverflow.com/questions/19845944/dynamic-function-calls-in-excel-vba[^]
 
Share this answer
 
Comments
adam.m.b.nelson 3-Feb-15 12:06pm    
Awesome, I'll try that out. Thanks you.
adam.m.b.nelson 3-Feb-15 12:39pm    
That worked, thank you!
ZurdoDev 3-Feb-15 13:05pm    
Good. You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900