In my previous question, How do I assign a value to a property where the property name is provided at run time in VBA? I learned how to use CallByName to set a property in a class at runtime.
This time, however, I'm trying to figure out how to get an object at runtime from a string.
For example, suppose I have a line with the following data: Worksheets("RAW DATA").Range("A1").QueryTable .
Here is what I can try to do where the above data to enter strParam below:
Function GetObject(strParam As String) As Object GetObject = SomeFunction(strParam) End Function
In this case, GetObject should return a QueryTable when evaluated using Worksheets("RAW DATA").Range("A1").QueryTable . Is there anything in VBA that can replace SomeFunction from the above example?
vba excel-vba excel
Ben mccormack
source share