Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a number of controls on my user form and am cycling through them. The
problem I have is that whenever I decide to add a new member to the group (frequently) it is given the item number according to the order it waqs placed on the page (i.e. if it is the 50th control number 50) when I want it to be (for exxample) number 10 since it an addition to an existing 1-9 option buttons and I want to cycle them. Sure I can cut every other control and repaste it and then the item number is as i want it but hopefully there is a more elegant solution ... anyone? Thanks and regards, Mark |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What did you want to do with the OptionButtons currently numbered 10, 11,
12, etc. then? If you automatically bump their number's up, wont' that screw up your code? Why aren't you using the GroupName property to group your controls (then the numbers wouldn't matter)? I presume when you say "cycle them", I presume you mean 'in code'. You would do that by examining the GroupName in your loop. For example, if the GroupName for one grouping of OptionButtons was "MyFirstGroup", then you could cycle each one with code like this... Dim C As Control For Each C In Me.Controls If TypeOf C Is msForms.OptionButton Then If C.GroupName = "MyFirstGroup" Then Debug.Print C.Name End If End If Next -- Rick (MVP - Excel) "Mark Stephens" wrote in message ... I have a number of controls on my user form and am cycling through them. The problem I have is that whenever I decide to add a new member to the group (frequently) it is given the item number according to the order it waqs placed on the page (i.e. if it is the 50th control number 50) when I want it to be (for exxample) number 10 since it an addition to an existing 1-9 option buttons and I want to cycle them. Sure I can cut every other control and repaste it and then the item number is as i want it but hopefully there is a more elegant solution ... anyone? Thanks and regards, Mark |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just to add, it is not possible to re-order index number of a controls on a
Userform. That means when you add a new control its index will be controls.count - 1 (as the first is zero). If you delete a control all subsequent index's will decrease correspondingly. No way to change that. You can build a form entirely with code to the form's "designer" object. For example, you could lay out all your details & properties in a table, add, amend, sort, etc, and go from there. But probably better to follow Rick's advice unless you want another learning curve ! Regards, Peter T "Mark Stephens" wrote in message ... I have a number of controls on my user form and am cycling through them. The problem I have is that whenever I decide to add a new member to the group (frequently) it is given the item number according to the order it waqs placed on the page (i.e. if it is the 50th control number 50) when I want it to be (for exxample) number 10 since it an addition to an existing 1-9 option buttons and I want to cycle them. Sure I can cut every other control and repaste it and then the item number is as i want it but hopefully there is a more elegant solution ... anyone? Thanks and regards, Mark |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another option is to add controls at runtime instead. If you are adding
controls as frequently as seems to suggest, it will give you a great deal of flexibility and power. It's a big difference from how you are doing it now, but it can take your project to a higher level. -- Tim Zych http://www.higherdata.com Compare data in Excel and find differences with Workbook Compare Free and Pro versions available "Mark Stephens" wrote in message ... I have a number of controls on my user form and am cycling through them. The problem I have is that whenever I decide to add a new member to the group (frequently) it is given the item number according to the order it waqs placed on the page (i.e. if it is the 50th control number 50) when I want it to be (for exxample) number 10 since it an addition to an existing 1-9 option buttons and I want to cycle them. Sure I can cut every other control and repaste it and then the item number is as i want it but hopefully there is a more elegant solution ... anyone? Thanks and regards, Mark |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tim/aa,
Thanks for your suggestions....Tim's idea of adding at runtime seems to be a good option, it shouldn't be too much extra work and as you say it wil give me flexibility (actually I could for example have a sheet with column a containing button captions, and have a routine count the number and name them accordingly, that way I can change a lot). Thanks for the suggestion, regards, Mark "Tim Zych" <feedback at higherdata dt com wrote in message ... Another option is to add controls at runtime instead. If you are adding controls as frequently as seems to suggest, it will give you a great deal of flexibility and power. It's a big difference from how you are doing it now, but it can take your project to a higher level. -- Tim Zych http://www.higherdata.com Compare data in Excel and find differences with Workbook Compare Free and Pro versions available "Mark Stephens" wrote in message ... I have a number of controls on my user form and am cycling through them. The problem I have is that whenever I decide to add a new member to the group (frequently) it is given the item number according to the order it waqs placed on the page (i.e. if it is the 50th control number 50) when I want it to be (for exxample) number 10 since it an addition to an existing 1-9 option buttons and I want to cycle them. Sure I can cut every other control and repaste it and then the item number is as i want it but hopefully there is a more elegant solution ... anyone? Thanks and regards, Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
User Form with dropdown item | Excel Discussion (Misc queries) | |||
Adding a control to a User Form | Excel Programming | |||
user form & control properties | Excel Programming | |||
user form and frame control | Excel Programming | |||
Control Order on User Form | Excel Programming |