Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Groups of controls

I use different groups of controls in an excel sheet.
Each time a control in one group is clicked, I would like the controls
of the other groups to turn to "False".
I know how to code it control after control, but this is quite tedious!
Is ther any kind of code that could go "For all controls in group X,
when control is clicked, value of all controls in group Y and Z go to
False" ?
Thanks in advance,
Franck

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Groups of controls

What sort of controls,, ActiveX or forms, and what do you mean by turn to
False?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"FB" wrote in message
oups.com...
I use different groups of controls in an excel sheet.
Each time a control in one group is clicked, I would like the controls
of the other groups to turn to "False".
I know how to code it control after control, but this is quite tedious!
Is ther any kind of code that could go "For all controls in group X,
when control is clicked, value of all controls in group Y and Z go to
False" ?
Thanks in advance,
Franck



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Groups of controls

These are ActiveX controls. They are linked to cells. When a control is
clicked, I would like the values of the cells linked to the controls in
the other groups to turn to 'False'. For now, I use stuff like

Private Sub CbxChina_Click()
If Range("AA7").FormulaR1C1 = "TRUE" Then
Range("AA5").FormulaR1C1 = "TRUE"
Range("AA4").FormulaR1C1 = "FALSE"
Range("AA6").FormulaR1C1 = "FALSE"
Range("AA15:AA22").FormulaR1C1 = "FALSE"
Range("AB4:AB29").FormulaR1C1 = "FALSE"
End If
End Sub

for individual controls, but as I have about 50 controls on my sheet, I
cannot do this systematically!

Franck

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Groups of controls

They're a bit inconsistent(!) in Office - in some apps you can talk about the
collection of all Controls while in others you have to be more specific
(TextBoxes, CheckBoxes, Buttons, etc). As far as I can see, Excel forms are
the latter but you can still save time by using a For...Each loop and
hopefully you haven't got too wide a selection of different types of control.
For example, the following will cycle around all checkboxes making them
False (you could use an If, perhaps with myChk.Name, to be more specific):

Dim myChk As CheckBox
For Each myChk In ActiveSheet.CheckBoxes
myChk.Value = False
Next myChk



"FB" wrote:

I use different groups of controls in an excel sheet.
Each time a control in one group is clicked, I would like the controls
of the other groups to turn to "False".
I know how to code it control after control, but this is quite tedious!
Is ther any kind of code that could go "For all controls in group X,
when control is clicked, value of all controls in group Y and Z go to
False" ?
Thanks in advance,
Franck


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Groups of controls

Thanks. What I would like to do is something like

Dim myChk As CheckBox
For Each myChk In <Group of Checboxes #1

Is it possible?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Groups of controls

You can test a group like this

Dim ctl As Object
Dim i As Long

Application.EnableEvents = False
On Error Resume Next
For Each ctl In ActiveSheet.OLEObjects
If ctl.Object.GroupName = "xxx" Then
If Err.Number = 0 Then
Range(ctl.LinkedCell).Value = False
End If
End If
Next ctl

On Error GoTo 0
Application.EnableEvents = True

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"FB" wrote in message
ups.com...
These are ActiveX controls. They are linked to cells. When a control is
clicked, I would like the values of the cells linked to the controls in
the other groups to turn to 'False'. For now, I use stuff like

Private Sub CbxChina_Click()
If Range("AA7").FormulaR1C1 = "TRUE" Then
Range("AA5").FormulaR1C1 = "TRUE"
Range("AA4").FormulaR1C1 = "FALSE"
Range("AA6").FormulaR1C1 = "FALSE"
Range("AA15:AA22").FormulaR1C1 = "FALSE"
Range("AB4:AB29").FormulaR1C1 = "FALSE"
End If
End Sub

for individual controls, but as I have about 50 controls on my sheet, I
cannot do this systematically!

Franck



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Groups of controls

Looks fine. Thank you!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Groups of controls

Only indirectly, i.e. if you've given the checkboxes names that reflect their
group. Then you could do something like:

If Left(myChk.Name,4) = "grp1" then myChk.Value = False

"FB" wrote:

Thanks. What I would like to do is something like

Dim myChk As CheckBox
For Each myChk In <Group of Checboxes #1

Is it possible?


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
Excel - Sorting groups in groups due to subtotaling [email protected] Excel Worksheet Functions 3 April 4th 08 06:13 PM
ActiveX Controls vs Form Controls Alex Excel Discussion (Misc queries) 1 January 11th 06 08:46 AM
Event procedures for controls added with Controls.Add John Austin[_4_] Excel Programming 1 March 9th 05 03:31 PM
how do i view all groups under excel in google groups JulieD Excel Discussion (Misc queries) 2 December 16th 04 04:33 PM
resizing and aligning groups of ActiveX controls together Paul James[_3_] Excel Programming 3 September 5th 03 04:05 PM


All times are GMT +1. The time now is 06:56 AM.

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

About Us

"It's about Microsoft Excel"