Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable TextBox
Dear All
Following code is simple: ..... For i=1 To 7 Worksheets("Sheet"&i).Range("A1").Value = i*2 Next i ..... But if I want to do that with a TextBox how can I do that if I have TextBox1 to TextBox7: ..... For i=1 To 7 TextBox i .Value = i*2 Next i ..... How do I program the line within the loop? I know, it would not work like that. Thanks Philipp |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable TextBox
I found a way to do it:
For i=1 To 7 Dim ctl As Control For Each ctl In Controls If TypeName(ctl) = "TextBox" Then If ctl.Name = "TextBox" &i Then ctl.Value = i*2 End If End If Next Next i If someone knows a more elgant way please let me know. Cheer Philipp Philipp Schramek schrieb: Dear All Following code is simple: .... For i=1 To 7 Worksheets("Sheet"&i).Range("A1").Value = i*2 Next i .... But if I want to do that with a TextBox how can I do that if I have TextBox1 to TextBox7: .... For i=1 To 7 TextBox i .Value = i*2 Next i .... How do I program the line within the loop? I know, it would not work like that. Thanks Philipp |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable TextBox
For i=1 To 7
Userform1.Controls("TextBox" &i).Value = i*2 Next i Might be a bit more compact. -- Regards, Tom Ogilvy "Philipp Schramek" wrote in message ... I found a way to do it: For i=1 To 7 Dim ctl As Control For Each ctl In Controls If TypeName(ctl) = "TextBox" Then If ctl.Name = "TextBox" &i Then ctl.Value = i*2 End If End If Next Next i If someone knows a more elgant way please let me know. Cheer Philipp Philipp Schramek schrieb: Dear All Following code is simple: .... For i=1 To 7 Worksheets("Sheet"&i).Range("A1").Value = i*2 Next i .... But if I want to do that with a TextBox how can I do that if I have TextBox1 to TextBox7: .... For i=1 To 7 TextBox i .Value = i*2 Next i .... How do I program the line within the loop? I know, it would not work like that. Thanks Philipp |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
Calculate Textbox value based on another textbox value.doc | Excel Discussion (Misc queries) | |||
Calculate Textbox value based on another textbox value | Excel Discussion (Misc queries) | |||
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 |