PDA

View Full Version : Is this possible in VBA ????? ( rexx interpret command)



gonen
06-09-2014, 02:08 AM
Hi

can this be done in VBA ? -

a = "myname"
value of a = "bbb"

debug.print myname ==>>> will print "bbb"

============================================


For those who are familiar with rexx interpret command it is obvious

For those who are not my question is:


is it possible to assign a value to VBA variable whose name is stored in another variable ?



thanks for your help

Aflatoon
06-09-2014, 02:22 AM
Typically, no, but if the variable is declared in an object module, then you can use CallByName to, well, call it by name.

jonh
06-09-2014, 06:48 AM
You can refer to objects in a collection by name.


Dim col As New Collection
...
col.Add New Class1, "myname"
col("myname").Value = "aaa"
Debug.Print col("myname").Value