![]() |
How to enter a Range of TextBoxes?
Here is my redundant code,
TextBox1.Visible = False TextBox2.Visible = False TextBox3.Visible = False TextBox4.Visible = False TextBox5.Visible = False TextBox6.Visible = False TextBox7.Visible = False TextBox8.Visible = False TextBox9.Visible = False TextBox10.Visible = False TextBox11.Visible = False TextBox12.Visible = False Is there a easier way to enter a range of textboxes lik (Textbox1:Textbox12).Visible = False. (This did not work). P.S. - The textboxes are from the Control ToolBox -- Message posted from http://www.ExcelForum.com |
How to enter a Range of TextBoxes?
If they're located in a Userform:
Dim i As Long For i = 1 to 12 Me.Controls("TextBox" & i).Visible = False Next i -- Regards, Juan Pablo González "bg18461 " wrote in message ... Here is my redundant code, TextBox1.Visible = False TextBox2.Visible = False TextBox3.Visible = False TextBox4.Visible = False TextBox5.Visible = False TextBox6.Visible = False TextBox7.Visible = False TextBox8.Visible = False TextBox9.Visible = False TextBox10.Visible = False TextBox11.Visible = False TextBox12.Visible = False Is there a easier way to enter a range of textboxes like (Textbox1:Textbox12).Visible = False. (This did not work). P.S. - The textboxes are from the Control ToolBox. --- Message posted from http://www.ExcelForum.com/ |
How to enter a Range of TextBoxes?
But as they are control tolbox textboxes use
Dim i As Long For i = 1 To 12 Worksheets("Sheet1").OLEObjects("TextBox" & i).Visible = False Next i -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Juan Pablo Gonzalez" wrote in message ... If they're located in a Userform: Dim i As Long For i = 1 to 12 Me.Controls("TextBox" & i).Visible = False Next i -- Regards, Juan Pablo González "bg18461 " wrote in message ... Here is my redundant code, TextBox1.Visible = False TextBox2.Visible = False TextBox3.Visible = False TextBox4.Visible = False TextBox5.Visible = False TextBox6.Visible = False TextBox7.Visible = False TextBox8.Visible = False TextBox9.Visible = False TextBox10.Visible = False TextBox11.Visible = False TextBox12.Visible = False Is there a easier way to enter a range of textboxes like (Textbox1:Textbox12).Visible = False. (This did not work). P.S. - The textboxes are from the Control ToolBox. --- Message posted from http://www.ExcelForum.com/ |
How to enter a Range of TextBoxes?
Thanks for everyone's responses so far, I do appreciate it, now back t
the code. Below shows the code and the error as I have it in my program, an hints... Private Sub OptionButton1_Click() Dim i As Long For i = 23 To 190 Worksheets("Sheet4").OLEObjects("Label" & i).Visible = False Next i ERROR: Run-time error '9': Subscript out of rang -- Message posted from http://www.ExcelForum.com |
How to enter a Range of TextBoxes?
That would suggest that Sheet4 doesn't exits, or one of the Texboxes 23 to
190 doesn't exist. When it occurs, get the error in debug. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "bg18461 " wrote in message ... Thanks for everyone's responses so far, I do appreciate it, now back to the code. Below shows the code and the error as I have it in my program, any hints... Private Sub OptionButton1_Click() Dim i As Long For i = 23 To 190 Worksheets("Sheet4").OLEObjects("Label" & i).Visible = False Next i ERROR: Run-time error '9': Subscript out of range --- Message posted from http://www.ExcelForum.com/ |
How to enter a Range of TextBoxes?
Ok, I got rid of error 9 (subscript out of range) - wrong sheet name
however this error has been surplanted by 'Run-time error 438' - Objec doesn't support this property or method. Here is my code: Dim i As Long For i = 16 To 31 Worksheets("INSRD VEH PASS").OLEObjects("OptionButton" & i).BackColor &HFFFF& Next i It appears to not like the OLEObjects method, but I cannot figure out way around this. Any suggestions.. -- Message posted from http://www.ExcelForum.com |
How to enter a Range of TextBoxes?
Try this
Dim i As Long For i = 16 To 31 Worksheets("Sheet1").OLEObjects("OptionButton" & i).Object.BackColor = &HFFFF& Next i -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "bg18461 " wrote in message ... Ok, I got rid of error 9 (subscript out of range) - wrong sheet name, however this error has been surplanted by 'Run-time error 438' - Object doesn't support this property or method. Here is my code: Dim i As Long For i = 16 To 31 Worksheets("INSRD VEH PASS").OLEObjects("OptionButton" & i).BackColor = &HFFFF& Next i It appears to not like the OLEObjects method, but I cannot figure out a way around this. Any suggestions... --- Message posted from http://www.ExcelForum.com/ |
How to enter a Range of TextBoxes?
You are the man! Thanks for your help, it worked :)
-- Message posted from http://www.ExcelForum.com |
How to enter a Range of TextBoxes?
Of course, re-instate your sheetname, not my test sheetname
Worksheets("INSRD VEH PASS").OLEObjects("OptionButton" & i).Object.BackColor = &HFFFF& -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Bob Phillips" wrote in message ... Try this Dim i As Long For i = 16 To 31 Worksheets("Sheet1").OLEObjects("OptionButton" & i).Object.BackColor = &HFFFF& Next i -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "bg18461 " wrote in message ... Ok, I got rid of error 9 (subscript out of range) - wrong sheet name, however this error has been surplanted by 'Run-time error 438' - Object doesn't support this property or method. Here is my code: Dim i As Long For i = 16 To 31 Worksheets("INSRD VEH PASS").OLEObjects("OptionButton" & i).BackColor = &HFFFF& Next i It appears to not like the OLEObjects method, but I cannot figure out a way around this. Any suggestions... --- Message posted from http://www.ExcelForum.com/ |
How to enter a Range of TextBoxes?
|
How to enter a Range of TextBoxes?
In article , bg18461
says... Thanks for everyone's responses so far, I do appreciate it, now back to the code. Below shows the code and the error as I have it in my program, any hints... Private Sub OptionButton1_Click() Dim i As Long For i = 23 To 190 Worksheets("Sheet4").OLEObjects("Label" & i).Visible = False Next i ERROR: Run-time error '9': Subscript out of range Weren't you working with Textboxes, not Labels? If there are fewer labels then textboxes then you'll get that error. See ya Ken McLennan Qld Australia |
All times are GMT +1. The time now is 12:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com