Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Selecting control on userform with part of control name (set question)

I have a select case statement, in which I determine which group of controls
("a", "b", "c", ..."j") I need to update (groups include radiobuttons,
checkboxes, etc.); e.g., group "a" includes cb_a, opt_a1T, opt_a1F, opt_a2T,
opt_A2F, etc.


Without looping through all controls (that would be a lot of extra
searching, with one full loop for each control) I'd like to be able to set
the control references dynamically, e.g.

Select Case
Case "Green"
Use_group = "a"
End Select

Set current_opt = "opt_" & Use_group & "1T" '<<<
current_opt.value = false

Can anyone point me to the correct syntax to directly select a control based
on control name?

Many thanks,
Keith


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Selecting control on userform with part of control name (set quest

Use this
OLEObjects(current_opt).object.value

"Keith" wrote:

I have a select case statement, in which I determine which group of controls
("a", "b", "c", ..."j") I need to update (groups include radiobuttons,
checkboxes, etc.); e.g., group "a" includes cb_a, opt_a1T, opt_a1F, opt_a2T,
opt_A2F, etc.


Without looping through all controls (that would be a lot of extra
searching, with one full loop for each control) I'd like to be able to set
the control references dynamically, e.g.

Select Case
Case "Green"
Use_group = "a"
End Select

Set current_opt = "opt_" & Use_group & "1T" '<<<
current_opt.value = false

Can anyone point me to the correct syntax to directly select a control based
on control name?

Many thanks,
Keith



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Selecting control on userform with part of control name (set quest

What settings (references, etc) do I need to use OLEObjects?
Thanks!!
Keith

"Alok" wrote in message
...
Use this
OLEObjects(current_opt).object.value

"Keith" wrote:

I have a select case statement, in which I determine which group of
controls
("a", "b", "c", ..."j") I need to update (groups include radiobuttons,
checkboxes, etc.); e.g., group "a" includes cb_a, opt_a1T, opt_a1F,
opt_a2T,
opt_A2F, etc.


Without looping through all controls (that would be a lot of extra
searching, with one full loop for each control) I'd like to be able to
set
the control references dynamically, e.g.

Select Case
Case "Green"
Use_group = "a"
End Select

Set current_opt = "opt_" & Use_group & "1T" '<<<
current_opt.value = false

Can anyone point me to the correct syntax to directly select a control
based
on control name?

Many thanks,
Keith





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Selecting control on userform with part of control name (set question)

Another general update; I think I'm closer, but still no dice-

I have 10 textboxes on userform1 named E1, E2, E3, etc. I want the
textbox.text (E1.text, etc.) to reflect the contents of an array

For z = 1 To 10
CurrObj = "E" & CStr(z) 'control string name
UserForm1.Controls(CurrObj).Text = CStr(EdArray(ShortEd,
z))
Next

I get error 438, object doesn't support this property or method

This is one of several sets of controls I want to update, but if I can get
one working, I can probably work out the rest- I'm just having trouble with
the syntax...

Thanks,
Keith

"Keith" wrote in message
...
I have a select case statement, in which I determine which group of
controls ("a", "b", "c", ..."j") I need to update (groups include
radiobuttons, checkboxes, etc.); e.g., group "a" includes cb_a, opt_a1T,
opt_a1F, opt_a2T, opt_A2F, etc.


Without looping through all controls (that would be a lot of extra
searching, with one full loop for each control) I'd like to be able to set
the control references dynamically, e.g.

Select Case
Case "Green"
Use_group = "a"
End Select

Set current_opt = "opt_" & Use_group & "1T" '<<<
current_opt.value = false

Can anyone point me to the correct syntax to directly select a control
based on control name?

Many thanks,
Keith



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Selecting control on userform with part of control name (set q

Thanks Alok- I'll give it a try!
:)
Keith

"Alok" wrote in message
...
This might help you..
Dim z%, CurrObj$, EdArray$(1 To 5)
Dim t As msforms.TextBox
Dim cnt As Control

EdArray(1) = "a"
EdArray(2) = "b"
EdArray(3) = "c"
EdArray(4) = "d"
EdArray(5) = "e"

For Each cnt In Controls
If TypeOf cnt Is msforms.TextBox Then
Set t = cnt
z = Mid$(cnt.Name, 2)
If Mid$(cnt.Name, 1) = "E" And z = LBound(EdArray) And z <=
UBound(EdArray) Then
t.Text = CStr(EdArray(z))
End If
End If
Next cnt


"Keith" wrote:

Another general update; I think I'm closer, but still no dice-

I have 10 textboxes on userform1 named E1, E2, E3, etc. I want the
textbox.text (E1.text, etc.) to reflect the contents of an array

For z = 1 To 10
CurrObj = "E" & CStr(z) 'control string name
UserForm1.Controls(CurrObj).Text =
CStr(EdArray(ShortEd,
z))
Next

I get error 438, object doesn't support this property or method

This is one of several sets of controls I want to update, but if I can
get
one working, I can probably work out the rest- I'm just having trouble
with
the syntax...

Thanks,
Keith

"Keith" wrote in message
...
I have a select case statement, in which I determine which group of
controls ("a", "b", "c", ..."j") I need to update (groups include
radiobuttons, checkboxes, etc.); e.g., group "a" includes cb_a, opt_a1T,
opt_a1F, opt_a2T, opt_A2F, etc.


Without looping through all controls (that would be a lot of extra
searching, with one full loop for each control) I'd like to be able to
set
the control references dynamically, e.g.

Select Case
Case "Green"
Use_group = "a"
End Select

Set current_opt = "opt_" & Use_group & "1T" '<<<
current_opt.value = false

Can anyone point me to the correct syntax to directly select a control
based on control name?

Many thanks,
Keith






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
Control for selecting cells in worksheets Mats Nilsson Excel Programming 2 June 29th 06 07:31 AM
Syntax for de-selecting a control? William DeLeo Excel Programming 1 February 18th 05 07:07 PM
Control Sequence from Userform Control Nigel Excel Programming 3 December 29th 04 01:25 PM
Flow of control in VBA Question - Userform Interaction Alan Excel Programming 3 December 23rd 04 01:12 PM
Selecting dates from ListBoxes by using RefEdit Control wpllc2004 Excel Programming 3 April 21st 04 07:36 AM


All times are GMT +1. The time now is 04:23 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"