Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default What order does VBA look at userform controls?

I have the following code ...

For Each CT In userform1
If TypeOf CT Is MSForms.TextBox Then
CT.Text = ThisWorkbook.Worksheets("sheet1").Range("A1")(2, i).Value
i = i + 1
Else: End If
Next CT

Now, the tab order of my form is textbox1,2,3,4,5,6,7,8,9. However, the vba
code produces the order textbox 1,2,6,7,3,4,5,8,9 ... This screws up my
attempt at populating the textboxes with the values from columns of a table
of data ...

How do I get it to go through them in the order I want?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default What order does VBA look at userform controls?

What order does VBA look at userform controls?Brad,
I believe that if you add textboxes to the form in the order that you want
to tab thru and to load them, the tab order and order in the collection will
be the same, but this is shaky ground. The most reliable way to access a
specific item in a collection is thru its index. In the case of textboxes
the textbox name is its index in the collection. If the names of each of
your textboxes were to end in one of a series of integers in some
significant order, it would be easy to specify the textboxes in order in a
counter controlled loop.

For i = 1 to 10
UserForm.Controls("Textbox" & Cstr(n)).Text = <something
Next i

Bob Kilmer

"Brad Patterson" wrote in message
...
I have the following code ...

For Each CT In userform1
If TypeOf CT Is MSForms.TextBox Then
CT.Text = ThisWorkbook.Worksheets("sheet1").Range("A1")(2, i).Value
i = i + 1
Else: End If
Next CT

Now, the tab order of my form is textbox1,2,3,4,5,6,7,8,9. However, the vba
code produces the order textbox 1,2,6,7,3,4,5,8,9 ... This screws up my
attempt at populating the textboxes with the values from columns of a table
of data ...

How do I get it to go through them in the order I want?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default What order does VBA look at userform controls?

What order does VBA look at userform controls?try something like

For i = 1 To 9
UserForm1.Controls("textbox" & i).Value = Range("a1").Offset(i, 0)
Next i

Lynn S
"Brad Patterson" wrote in message ...
I have the following code ...

For Each CT In userform1
If TypeOf CT Is MSForms.TextBox Then
CT.Text = ThisWorkbook.Worksheets("sheet1").Range("A1")(2, i).Value
i = i + 1
Else: End If
Next CT

Now, the tab order of my form is textbox1,2,3,4,5,6,7,8,9. However, the vba code produces the order textbox 1,2,6,7,3,4,5,8,9 ... This screws up my attempt at populating the textboxes with the values from columns of a table of data ...

How do I get it to go through them in the order I want?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default What order does VBA look at userform controls?

Typo!
Correction:

For i = 1 to 10
UserForm.Controls("Textbox" & Cstr(i)).Text = <something
Next i

"Bob Kilmer" wrote in message
...
What order does VBA look at userform controls?Brad,
I believe that if you add textboxes to the form in the order that you want
to tab thru and to load them, the tab order and order in the collection

will
be the same, but this is shaky ground. The most reliable way to access a
specific item in a collection is thru its index. In the case of textboxes
the textbox name is its index in the collection. If the names of each of
your textboxes were to end in one of a series of integers in some
significant order, it would be easy to specify the textboxes in order in a
counter controlled loop.

For i = 1 to 10
UserForm.Controls("Textbox" & Cstr(n)).Text = <something
Next i

Bob Kilmer

"Brad Patterson" wrote in message
...
I have the following code ...

For Each CT In userform1
If TypeOf CT Is MSForms.TextBox Then
CT.Text = ThisWorkbook.Worksheets("sheet1").Range("A1")(2, i).Value
i = i + 1
Else: End If
Next CT

Now, the tab order of my form is textbox1,2,3,4,5,6,7,8,9. However, the

vba
code produces the order textbox 1,2,6,7,3,4,5,8,9 ... This screws up my
attempt at populating the textboxes with the values from columns of a

table
of data ...

How do I get it to go through them in the order I want?




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
How to change series plotting order without changing legend order? PatrickM Charts and Charting in Excel 6 December 2nd 09 07:43 PM
For chart syles, why doesn't color order match series order? AMiller Charts and Charting in Excel 1 October 29th 09 12:02 AM
How stop Excel file UK date order changing to US order in m.merge Roger Aldridge Excel Discussion (Misc queries) 1 October 9th 07 11:52 PM
ActiveX Controls vs Form Controls Alex Excel Discussion (Misc queries) 1 January 11th 06 08:46 AM
Daily Macro to Download Data, Order and paste in order Iarla Excel Worksheet Functions 1 November 17th 04 01:59 PM


All times are GMT +1. The time now is 09:10 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"