Variable as name of object does not work - Why?
I actually have several thousand. I have 16 option buttons on each row set
up into three groups. Do you know if I can use a For Each loop?
-JEFF-
"Alok" wrote:
Unfortunately, this will not work because VBA sees the variable MyOB as a
string variable and not as an object variable.
If you are using 200 option buttons you have to write out 200 statements to
change the values.
Alok
"-JEFF-" wrote:
While trying to make changes to a large number of option buttons on a sheet,
I want to increment a number and concactinate it in order to change the
correct optionbutton. But this does not work:
Sub MySub
dim i
i = 1
for i = 1 to 200
MyOB = "OptionButton" & trim(str(i))
MyOB.value = False 'or any of the other properties I need to change
next i
end
It does work when I use the actual optionbutton name instead of the
variable, i.e. OptionButton2.value = False
-JEFF-
|