Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cycle through controls with similar names

I have made a user form which allows the user to select a
number of groups all with the same parameters. Hence, I
have 6 of every control used for selection (text boxes
and combo boxes) and I have named the txt1, txt2, through
to txt6. I want to be able to do the same thing to each
control within a loop like you could do if these were
named ranges (e.g. Range("txt" & grp)). Is there a way
to do this?

I had also thought of directly linking each text box to a
cell using the ControlSource property. The problem is
that I want to be able to move these ranges if I need to
so that I can add more options later. I have found that
if you enter an address then this does not get moved if
you move the cell. I tried linking them to a named range
but this also seems to continue linking to the original
cell rather than moving to the range where the name is
now.

Can somebody point me in the direction of some useful
instructions on either cycling through control names or
linking directly to cells or towards a more efficient
method.

Thanks!

Tim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cycle through controls with similar names


For i = 1 To 6
Me.Controls("txt" & i).Text = i
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tim Archer" wrote in message
...
I have made a user form which allows the user to select a
number of groups all with the same parameters. Hence, I
have 6 of every control used for selection (text boxes
and combo boxes) and I have named the txt1, txt2, through
to txt6. I want to be able to do the same thing to each
control within a loop like you could do if these were
named ranges (e.g. Range("txt" & grp)). Is there a way
to do this?

I had also thought of directly linking each text box to a
cell using the ControlSource property. The problem is
that I want to be able to move these ranges if I need to
so that I can add more options later. I have found that
if you enter an address then this does not get moved if
you move the cell. I tried linking them to a named range
but this also seems to continue linking to the original
cell rather than moving to the range where the name is
now.

Can somebody point me in the direction of some useful
instructions on either cycling through control names or
linking directly to cells or towards a more efficient
method.

Thanks!

Tim



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
similar names - two spreadsheets jtkuehn Excel Worksheet Functions 3 August 28th 08 10:07 PM
See names of controls TheMath Excel Discussion (Misc queries) 2 July 7th 06 06:06 PM
SIMILAR NAMES IN A TABLE Dimitri Kryukov Excel Discussion (Misc queries) 5 June 28th 05 03:27 PM
How to cycle through a series of similar objects with a for-next loop? Derrick Vandekraats Excel Programming 5 September 30th 04 04:22 AM
Cycle trhough a list of names Pete Excel Programming 3 December 19th 03 02:09 PM


All times are GMT +1. The time now is 03:44 PM.

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

About Us

"It's about Microsoft Excel"