![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Arkansas
Posts: 358
|
Hi Im kind of new at this vb, trying hard to learn it. I have a form with frames. Nead to create a control array and have no idea of what I am doing.. Please help. Thx Dan
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Not sure exactly what you mean by control array or what you want. But try the following code:
Dim toppostition, counter As Integer counter = 5 For I = 1 To counter Set myoptionbuttons(I) = MyFrame.Controls.Add("Forms.optionbutton.1") myoptionbuttons(I).Left = 0 myoptionbuttons(I).Top = topposition myoptionbuttons(I).Width = 66 myoptionbuttons(I).Height = 18 myoptionbuttons(I).value= false myoptionbuttons(I).caption = Range("A" & counter).Value topposition = topposition + 18 Next I This code will place 5 optionbuttons underneath each other starting at the top left corner of a frame called "MyFrame" and set the caption to the values in cells A1 through A5. _________________ Hope this helps. Kind regards, Al. [ This Message was edited by: Al Chara on 2002-03-22 19:38 ] |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Arkansas
Posts: 358
|
My problem is under this frame all option boxes have the same name with different captions. And I keep getting the error message - ambigouos name.
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
You cannot create a control array in VBA unless something has changed...
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Each object must have it's own unique name
A control array with optionbuttons for ex. would look like the following optionbutton(0).caption optionbutton(1).caption optionbutton(2).caption optionbutton(3).caption Unless VBA 6.0 has changed from 5.0, you cannot create a control array |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
See my code above, I updated it to fit your needs.
__________________
Kind regards, Al Chara |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|