Declare Variables for CheckBos Object
Posted by John Bennito on January 31, 2002 10:44 AM
In a UserForm I have about 25 checkboxes that I have named CB1 through CB25. When I call up the UserForm I would like the Userform_activate code to check which Columns 1 through 25 on the worksheet have been hidden on the worksheet. If they are hidden, I would like to check the box (set value of checkbox to "true").
I proposed to do it in a loop as follows.
For x = 1 to 25
if activesheet.column(x).width = 0 then
mm = "Userform.cb" & x
mm.value = true
else
mm = "Userform.cb" & x
mm.value = False
end if
Next x
I have tried declaring "mm" as an object varible and used the set command also but to no avail.
However the code only works if I hardcode the name of the checkbox - it does not like the variable x. Is there a way to define the variable - or will I have to hard code the names and not do them in a loop.
Please advise.
Thanks