Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() say you have 3 textboxes called txt1, txt2 and txt3. It's possible to cycle thru these controls by using the following... for i = 1 to 3 msgbox .controls("txt" & i).value next i can this be done with variables names? i.e. variable1, variable2, variable3 help gratefully accepted! Thanks, Matt -- MattShoreso ----------------------------------------------------------------------- MattShoreson's Profile: http://www.excelforum.com/member.php...nfo&userid=347 View this thread: http://www.excelforum.com/showthread.php?threadid=57142 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That should work.
variable1 = "txt1" MsgBox Userform1.Controls(variable1).value Charles MattShoreson wrote: say you have 3 textboxes called txt1, txt2 and txt3. It's possible to cycle thru these controls by using the following... for i = 1 to 3 msgbox .controls("txt" & i).value next i can this be done with variables names? i.e. variable1, variable2, variable3 help gratefully accepted! Thanks, Matt. -- MattShoreson ------------------------------------------------------------------------ MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472 View this thread: http://www.excelforum.com/showthread...hreadid=571424 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, not possible.
Create an array, and cycle through that aryValues = Array(1,2,3,4) For i = Lbound(aryValues) to Ubound(aryValues) MsgBox aryValues(i) Next i -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "MattShoreson" wrote in message news:MattShoreson.2cjcr4_1155568508.9407@excelforu m-nospam.com... say you have 3 textboxes called txt1, txt2 and txt3. It's possible to cycle thru these controls by using the following... for i = 1 to 3 msgbox .controls("txt" & i).value next i can this be done with variables names? i.e. variable1, variable2, variable3 help gratefully accepted! Thanks, Matt. -- MattShoreson ------------------------------------------------------------------------ MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472 View this thread: http://www.excelforum.com/showthread...hreadid=571424 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() thanks bob. Realised that I had to do it this way. Think it's getting a little late in the day! A collection of variables = an array! -- MattShoreson ------------------------------------------------------------------------ MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472 View this thread: http://www.excelforum.com/showthread...hreadid=571424 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this should do what you want. mine are textbox1 thru textbox3
Private Sub CommandButton1_Click() For i = 1 To 3 MsgBox Me.Controls("textBox" & i) Next End Sub -- Gary "MattShoreson" wrote in message news:MattShoreson.2cjcr4_1155568508.9407@excelforu m-nospam.com... say you have 3 textboxes called txt1, txt2 and txt3. It's possible to cycle thru these controls by using the following... for i = 1 to 3 msgbox .controls("txt" & i).value next i can this be done with variables names? i.e. variable1, variable2, variable3 help gratefully accepted! Thanks, Matt. -- MattShoreson ------------------------------------------------------------------------ MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472 View this thread: http://www.excelforum.com/showthread...hreadid=571424 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
variable height variable width stacked bar charts | Charts and Charting in Excel | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
Run-time error '91': "Object variable or With block variable not set | Excel Programming | |||
Cells.Find error Object variable or With block variable not set | Excel Programming | |||
Pivot Table - Object variable or with block variable not set? | Excel Programming |