-1

Suppose my class has a couple of similar properties and I want to select one dynamically based on a string variable:

MyClass properties:
PropertyOne
PropertyTwo

Some generic code:
myString = "One"
MyClass.Property & myString = "blah" 'this doesn't work

0

1 Answer 1

0
CallByName MyClass, "PropertyOne", vbLet, "blah"

https://msdn.microsoft.com/VBA/Language-Reference-VBA/articles/callbyname-function

Sign up to request clarification or add additional context in comments.

2 Comments

Can I do something like this: CallByName MyClass, Property & myString, vbLet, "blah"
@user5689314 yes but it has to be a string: "Property" & myString

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.