Hi,
I've searched google and your forum, but couldn't find anything that would help me.
I'm running Excel 2002 SP-2 with VBA 6.3.
I have a userform that contains a series of OptionButtons, named: OptionButton1, OptionButton2, ..., OptionButton20.
Also, I have a name in my worksheet that contains a dynamic array, named: nameList
I want to count the number of entries in this dynamic list and set the options of visibility of each OptionButton accordingly to this count.
The problem is that I've tried to use an eval command, just like in matlab where a string can be used to set a command, but it doesn't work. Also, I've tried to use the application.evaluate and it does nothing. For example:
Private Sub UserForm_Activate()
Dim rangeList As range
Dim ws As Worksheet
Dim i As Integer
Dim count As Integer
Set ws = Worksheets("worksheet_lists")
i = 0
For Each rangeList In ws.range("nameList")
i = i + 1
Next rangeList
For count = i To 20 ' "i" will never be greater than 20
eval ("me.OptionButton" & i & ".Visible = False")
Next i
End Sub
Display More
As I said, I've tried to change the count loop to :
For count = i To 20 ' i will never be greater than 20
Application.Evaluate("me.OptionButton" & i & ".Visible = False")
Next i
and it still doesn't work. Also, I've tried to create a GroupName, thinking that the OptionButton object would be inside of that groupname, but the groupname became a property of the OptionButton. The same happens with the frame, or the multi-page.
Any thoughts on how can I do this?
Thanks!