Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Specifying Item number of control on user form

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Specifying Item number of control on user form

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Specifying Item number of control on user form

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Specifying Item number of control on user form

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Specifying Item number of control on user form

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Form with dropdown item Gene Augustin Excel Discussion (Misc queries) 0 February 18th 09 06:35 PM
Adding a control to a User Form scantor145[_22_] Excel Programming 1 October 17th 05 09:27 PM
user form & control properties Mike Molyneaux Excel Programming 0 April 1st 05 07:41 PM
user form and frame control Gixxer_J_97[_2_] Excel Programming 1 February 11th 05 10:26 PM
Control Order on User Form AKoodray Excel Programming 4 December 30th 03 09:30 PM


All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"