98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Functions and String variables
Functions and String variables
Resolved · Low Priority · Version 2007
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
Mon 21 May 2012: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |