Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA -making Objectnames variable

Thanks!!!
problem solve

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
making a portion of reference to a worksheet variable in a formula Celia Excel Discussion (Misc queries) 1 October 25th 09 08:27 AM
Making part of a formula a variable Will Fleenor Excel Worksheet Functions 2 August 14th 09 01:19 PM
Making a Call to an external sheet using a variable... [email protected] Excel Worksheet Functions 2 January 19th 07 03:19 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Making a file and worksheet reference into a variable.... Mr Mike Excel Worksheet Functions 3 July 6th 05 08:52 PM


All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"