Lukas has attended:
Excel VBA Intro Intermediate course
Functions and String variables
Can I use the value of a string variable as a building block for vba code akin to the "indirect" worksheet function? For example, if I would like to write my own "countif" function, I would need to define what operator to apply (e.g. greater than, equal to etc). I would probably capture this in the argument line using a string variable. SO how do I tell VBA that the value of the string should actually be read as active code?
Cheers,
Lukas
RE: Functions and String variables
Hi Lukas, thanks for your query. Two things suggest themselves here. First, you can pass an object to another subroutine or function, alter it, and if you are using ByRef, it will update back in your original subroutine. This is, for example, how you build recursive code for, say, looping through however many folders and subfolders you might have.
Secondly, you could of course go all the way and concatenate together an entire text file of code strings, then import that into your project as a new module and call the new functions.
http://www.exceltip.com/show_tip/Modules ,_Class_Modules_in_VBA/Insert_a_new_module_from_a_file_using_VBA_in_Microsoft_Excel/507.html
What you'll end up with is code that writes code....
Hope this helps,
Anthony