Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm a newbie and have this problem:
I have 13 textboxes called MN1, MN2, MN3 ...... MN13 when trying to set text in all of them i did this: for i 1 to 13 Dim Temp as object Set Temp = "MN" & i temp.text = "test" next i How do i refer to an object whith i in a loop?? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
Dim i As Long For i = 1 to ActiveSheet.Textboxes.Count ActiveSheet.Textboxes(i).Text = "test" Next i Another: Dim tbTemp As TextBox For Each tbTemp In ActiveSheet.TextBoxes tbTemp.Text = "test" Next tbTemp In article , "Rune" wrote: I'm a newbie and have this problem: I have 13 textboxes called MN1, MN2, MN3 ...... MN13 when trying to set text in all of them i did this: for i 1 to 13 Dim Temp as object Set Temp = "MN" & i temp.text = "test" next i How do i refer to an object whith i in a loop?? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i didnt understand that....
all of the textboxes is in a form not on a sheet if i want to change the text in lats say MN2 using "MN" an i (or any index letter) how do i do that? "JE McGimpsey" wrote in message ... One way: Dim i As Long For i = 1 to ActiveSheet.Textboxes.Count ActiveSheet.Textboxes(i).Text = "test" Next i Another: Dim tbTemp As TextBox For Each tbTemp In ActiveSheet.TextBoxes tbTemp.Text = "test" Next tbTemp In article , "Rune" wrote: I'm a newbie and have this problem: I have 13 textboxes called MN1, MN2, MN3 ...... MN13 when trying to set text in all of them i did this: for i 1 to 13 Dim Temp as object Set Temp = "MN" & i temp.text = "test" next i How do i refer to an object whith i in a loop?? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
for i = 1 to 13
userform1.controls("MN" & i).Text = "Test" Next i -- Regards, Tom Ogilvy "Rune" wrote in message ... i didnt understand that.... all of the textboxes is in a form not on a sheet if i want to change the text in lats say MN2 using "MN" an i (or any index letter) how do i do that? "JE McGimpsey" wrote in message ... One way: Dim i As Long For i = 1 to ActiveSheet.Textboxes.Count ActiveSheet.Textboxes(i).Text = "test" Next i Another: Dim tbTemp As TextBox For Each tbTemp In ActiveSheet.TextBoxes tbTemp.Text = "test" Next tbTemp In article , "Rune" wrote: I'm a newbie and have this problem: I have 13 textboxes called MN1, MN2, MN3 ...... MN13 when trying to set text in all of them i did this: for i 1 to 13 Dim Temp as object Set Temp = "MN" & i temp.text = "test" next i How do i refer to an object whith i in a loop?? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you!!!.. that solved my problem :D
"Tom Ogilvy" wrote in message ... for i = 1 to 13 userform1.controls("MN" & i).Text = "Test" Next i -- Regards, Tom Ogilvy "Rune" wrote in message ... i didnt understand that.... all of the textboxes is in a form not on a sheet if i want to change the text in lats say MN2 using "MN" an i (or any index letter) how do i do that? "JE McGimpsey" wrote in message ... One way: Dim i As Long For i = 1 to ActiveSheet.Textboxes.Count ActiveSheet.Textboxes(i).Text = "test" Next i Another: Dim tbTemp As TextBox For Each tbTemp In ActiveSheet.TextBoxes tbTemp.Text = "test" Next tbTemp In article , "Rune" wrote: I'm a newbie and have this problem: I have 13 textboxes called MN1, MN2, MN3 ...... MN13 when trying to set text in all of them i did this: for i 1 to 13 Dim Temp as object Set Temp = "MN" & i temp.text = "test" next i How do i refer to an object whith i in a loop?? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Within the userform:
Me.Controls("MN" & i).Text = "test" External to the userform: MyForm.Controls("MN" & i).Text = "test" where MyForm is your userform instance. In article , "Rune" wrote: i didnt understand that.... all of the textboxes is in a form not on a sheet if i want to change the text in lats say MN2 using "MN" an i (or any index letter) how do i do that? |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
JE shows how to do it with a textbox from the drawing toolbar or on a
MACintosh. For an activeX textbox in Windows Dim oleObj as OleObject for each oleObj in activesheet.OleObjects if typeof oleObj.Object is MSforms.Textbox then oleObj.Object.Value = "Test" end if Next or if you have more than these textboxes for i = 1 to 13 activesheet.OleObjects("MN" & i ).Value = "Test" Next -- Regards, Tom Ogilvy "JE McGimpsey" wrote in message ... One way: Dim i As Long For i = 1 to ActiveSheet.Textboxes.Count ActiveSheet.Textboxes(i).Text = "test" Next i Another: Dim tbTemp As TextBox For Each tbTemp In ActiveSheet.TextBoxes tbTemp.Text = "test" Next tbTemp In article , "Rune" wrote: I'm a newbie and have this problem: I have 13 textboxes called MN1, MN2, MN3 ...... MN13 when trying to set text in all of them i did this: for i 1 to 13 Dim Temp as object Set Temp = "MN" & i temp.text = "test" next i How do i refer to an object whith i in a loop?? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Looping | Excel Discussion (Misc queries) | |||
Not Looping | Excel Discussion (Misc queries) | |||
looping to End | Excel Programming | |||
Looping | Excel Programming | |||
Looping | Excel Programming |