Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA -making Objectnames variable
Hi,
I have X objects on a Form on which the same actions need to be done a initialisation. Does anyone know how I can do this without typing th code for all objects. what I have tried from i=1 to end tickbox= "object" & i With tickbox .value=true .enabled= true .visible=true next i The problem that I have is that I don't get VBA to recognise th varuiable tickbox as an objectname, tho there is an object name "objectname1" Can anyone help Thnx -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA -making Objectnames variable
Hi Bijl167,
Try: Private Sub UserForm_Initialize() Dim ctrl As Control For Each ctrl In Me.Controls If TypeName(ctrl) = "CheckBox" Then With ctrl .Value = True .Enabled = True .Visible = True End With End If Next End Sub --- Regards, Norman "Bijl167 " wrote in message ... Hi, I have X objects on a Form on which the same actions need to be done at initialisation. Does anyone know how I can do this without typing the code for all objects. what I have tried from i=1 to end tickbox= "object" & i With tickbox value=true enabled= true visible=true next i The problem that I have is that I don't get VBA to recognise the varuiable tickbox as an objectname, tho there is an object named "objectname1" Can anyone help Thnx! --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA -making Objectnames variable
Assume your tickboxes are named CheckBox1 to Checkbox10
Private Sub Userform_Initialize() Dim i as long, lEnd as Long lEnd = 10 from i = 1 to lEnd With me.controls("Checkbox" & i") .value=true .enabled= true .visible=true End With next i End Sub -- Regards, Tom Ogilvy "Bijl167 " wrote in message ... Hi, I have X objects on a Form on which the same actions need to be done at initialisation. Does anyone know how I can do this without typing the code for all objects. what I have tried from i=1 to end tickbox= "object" & i With tickbox value=true enabled= true visible=true next i The problem that I have is that I don't get VBA to recognise the varuiable tickbox as an objectname, tho there is an object named "objectname1" Can anyone help Thnx! --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA -making Objectnames variable
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
making a portion of reference to a worksheet variable in a formula | Excel Discussion (Misc queries) | |||
Making part of a formula a variable | Excel Worksheet Functions | |||
Making a Call to an external sheet using a variable... | Excel Worksheet Functions | |||
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 | |||
Making a file and worksheet reference into a variable.... | Excel Worksheet Functions |