Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

Hi, Everyone:

I would appreciate if you can help me on this!


I have two group box (Form) --- Group1 and Group2 --- on a regular
excel spreadsheet. There are 3 option buttons in Group1 and 7 option
buttons in Group2. I must select ONE AND ONLY ONE from each group
box.
What I am trying to do is: If option button 1 in Group1 is clicked,
then ONE AND ONLY ONE of all 7 option buttons in Group2 is able to be
clicked. However, if option button 2 in Group1 is clicked, then ONE
AND ONLY ONE of two option buttons in Group2 is able to be clicked
(the other 5 option buttons will be greyed out). Option button 3 in
Group 1 is similiar to Option button 2.


Thank you,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default need help on how to grey out one option button in one group box ba

Hi George
How about something like:
In design mode change Group2 optbuttons to Enabled = False

Then in code (untested)
Dim ctrl
If Group1.optbtn1 = True Then
For each ctrl in Group2.Controls
ctrl.Enabled = True
Next ctrl
Elseif Group1.optbtn2 = True or Group1.optbtn2 = True then
Group2.optbtn1 = True
Group2.optbtn2 = True
End if

hth

Geoff

"George" wrote:

Hi, Everyone:

I would appreciate if you can help me on this!


I have two group box (Form) --- Group1 and Group2 --- on a regular
excel spreadsheet. There are 3 option buttons in Group1 and 7 option
buttons in Group2. I must select ONE AND ONLY ONE from each group
box.
What I am trying to do is: If option button 1 in Group1 is clicked,
then ONE AND ONLY ONE of all 7 option buttons in Group2 is able to be
clicked. However, if option button 2 in Group1 is clicked, then ONE
AND ONLY ONE of two option buttons in Group2 is able to be clicked
(the other 5 option buttons will be greyed out). Option button 3 in
Group 1 is similiar to Option button 2.


Thank you,


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default need help on how to grey out one option button in one group box ba

On Mar 8, 9:14 am, Geoff wrote:
Hi George
How about something like:
In design mode change Group2 optbuttons to Enabled = False

Then in code (untested)
Dim ctrl
If Group1.optbtn1 = True Then
For each ctrl in Group2.Controls
ctrl.Enabled = True
Next ctrl
Elseif Group1.optbtn2 = True or Group1.optbtn2 = True then
Group2.optbtn1 = True
Group2.optbtn2 = True
End if

hth

Geoff



"George" wrote:
Hi, Everyone:


I would appreciate if you can help me on this!


I have two group box (Form) --- Group1 and Group2 --- on a regular
excel spreadsheet. There are 3 option buttons in Group1 and 7 option
buttons in Group2. I must select ONE AND ONLY ONE from each group
box.
What I am trying to do is: If option button 1 in Group1 is clicked,
then ONE AND ONLY ONE of all 7 option buttons in Group2 is able to be
clicked. However, if option button 2 in Group1 is clicked, then ONE
AND ONLY ONE of two option buttons in Group2 is able to be clicked
(the other 5 option buttons will be greyed out). Option button 3 in
Group 1 is similiar to Option button 2.


Thank you,- Hide quoted text -


- Show quoted text -


Thanks, could you please show me how to do it in more details? Your
logic looks right, just not sure the details.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default need help on how to grey out one option button in one group bo

Hi George
one way:
Set up your form with 10 optbtns. GroupName btns 0 to 2 as Group1 and
optbtns 3 to 9 as Group2 or whatever. Then still in design mode change btns
3 to 9 from default Enabled = True to Enabled = False.
Then in the form code put:

Option Explicit

Private ctrl As Object, i As Integer

Private Sub optbtn1_Click()

Set ctrl = UserForms(0).Controls
For i = 3 To 9
ctrl(i).Enabled = True
Next

End Sub

Private Sub optbtn2_Click()

Set ctrl = UserForms(0).Controls
For i = 3 To 9
ctrl(i).Enabled = False
Next

optbtn4.Enabled = True
optbtn5.Enabled = True

End Sub

Private Sub optbtn3_Click()

Set ctrl = UserForms(0).Controls
For i = 3 To 9
ctrl(i).Enabled = False
Next

optbtn7.Enabled = True
optbtn8.Enabled = True

End Sub

hth

Geoff

"George" wrote:

On Mar 8, 9:14 am, Geoff wrote:
Hi George
How about something like:
In design mode change Group2 optbuttons to Enabled = False

Then in code (untested)
Dim ctrl
If Group1.optbtn1 = True Then
For each ctrl in Group2.Controls
ctrl.Enabled = True
Next ctrl
Elseif Group1.optbtn2 = True or Group1.optbtn2 = True then
Group2.optbtn1 = True
Group2.optbtn2 = True
End if

hth

Geoff



"George" wrote:
Hi, Everyone:


I would appreciate if you can help me on this!


I have two group box (Form) --- Group1 and Group2 --- on a regular
excel spreadsheet. There are 3 option buttons in Group1 and 7 option
buttons in Group2. I must select ONE AND ONLY ONE from each group
box.
What I am trying to do is: If option button 1 in Group1 is clicked,
then ONE AND ONLY ONE of all 7 option buttons in Group2 is able to be
clicked. However, if option button 2 in Group1 is clicked, then ONE
AND ONLY ONE of two option buttons in Group2 is able to be clicked
(the other 5 option buttons will be greyed out). Option button 3 in
Group 1 is similiar to Option button 2.


Thank you,- Hide quoted text -


- Show quoted text -


Thanks, could you please show me how to do it in more details? Your
logic looks right, just not sure the details.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default need help on how to grey out one option button in one group bo

On Mar 8, 1:36 pm, Geoff wrote:
Hi George
one way:
Set up your form with 10 optbtns. GroupName btns 0 to 2 as Group1 and
optbtns 3 to 9 as Group2 or whatever. Then still in design mode change btns
3 to 9 from default Enabled = True to Enabled = False.
Then in the form code put:

Option Explicit

Private ctrl As Object, i As Integer

Private Sub optbtn1_Click()

Set ctrl = UserForms(0).Controls
For i = 3 To 9
ctrl(i).Enabled = True
Next

End Sub

Private Sub optbtn2_Click()

Set ctrl = UserForms(0).Controls
For i = 3 To 9
ctrl(i).Enabled = False
Next

optbtn4.Enabled = True
optbtn5.Enabled = True

End Sub

Private Sub optbtn3_Click()

Set ctrl = UserForms(0).Controls
For i = 3 To 9
ctrl(i).Enabled = False
Next

optbtn7.Enabled = True
optbtn8.Enabled = True

End Sub

hth

Geoff



"George" wrote:
On Mar 8, 9:14 am, Geoff wrote:
Hi George
How about something like:
In design mode change Group2 optbuttons to Enabled = False


Then in code (untested)
Dim ctrl
If Group1.optbtn1 = True Then
For each ctrl in Group2.Controls
ctrl.Enabled = True
Next ctrl
Elseif Group1.optbtn2 = True or Group1.optbtn2 = True then
Group2.optbtn1 = True
Group2.optbtn2 = True
End if


hth


Geoff


"George" wrote:
Hi, Everyone:


I would appreciate if you can help me on this!


I have two group box (Form) --- Group1 and Group2 --- on a regular
excel spreadsheet. There are 3 option buttons in Group1 and 7 option
buttons in Group2. I must select ONE AND ONLY ONE from each group
box.
What I am trying to do is: If option button 1 in Group1 is clicked,
then ONE AND ONLY ONE of all 7 option buttons in Group2 is able to be
clicked. However, if option button 2 in Group1 is clicked, then ONE
AND ONLY ONE of two option buttons in Group2 is able to be clicked
(the other 5 option buttons will be greyed out). Option button 3 in
Group 1 is similiar to Option button 2.


Thank you,- Hide quoted text -


- Show quoted text -


Thanks, could you please show me how to do it in more details? Your
logic looks right, just not sure the details.- Hide quoted text -


- Show quoted text -


Thank you so much for your work. However, my option buttons are all
"Forms" Under View \ Toolbars once your open an excel spreadsheet. It
looks like you are talking about Userforms. Please clarify. Thanks
again and have a nice day!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

On Mar 8, 10:30 am, "merjet" wrote:
Are these option buttons from the Forms toolbar or the Control Toolbox
toolbar?
The VBA code would depend on which.

Merjet


Thanks, all optionbuttons and group boxes are from Forms Toolbars.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default need help on how to grey out one option button in one group boxbased on the selection of another option button in another group box

One way:

Option Explicit
Sub testme01()
With ActiveSheet
.OptionButtons.Enabled = False
.GroupBoxes.Enabled = False
End With
End Sub

You could use .visible = false, too.

George wrote:

On Mar 8, 10:30 am, "merjet" wrote:
Are these option buttons from the Forms toolbar or the Control Toolbox
toolbar?
The VBA code would depend on which.

Merjet


Thanks, all optionbuttons and group boxes are from Forms Toolbars.


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

The following is for 2 Option Buttons (#2 & #3) in Group1 and 4 in
Group2 (#5-#8), but it should be easy to adapt. Button5's value is set
to 1 in case one of the Buttons to be disabled is checked. It won't
"grey out", but it will disable.

Public Sub ControlOptions()
Dim ID As String
Dim OptBtn As Shape

ID = Application.Caller
Set OptBtn = ActiveSheet.Shapes(ID)

Select Case OptBtn.Name
Case Is = "Option Button 2"
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
True
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
True
Case Is = "Option Button 3"
ActiveSheet.OptionButtons("Option Button 5").Value = 1
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
False
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
False
End Select

End Sub

Hth,
Merjet


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

The following is for 2 Option Buttons (#2 & #3) in Group1 and 4 in
Group2 (#5-#8), but it should be easy to adapt. Button5's value is set
to 1 in case one of the Buttons to be disabled is checked. It won't
"grey out", but it will disable.

Public Sub ControlOptions()
Dim ID As String
Dim OptBtn As Shape

ID = Application.Caller
Set OptBtn = ActiveSheet.Shapes(ID)

Select Case OptBtn.Name
Case Is = "Option Button 2"
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
True
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
True
Case Is = "Option Button 3"
ActiveSheet.OptionButtons("Option Button 5").Value = 1
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
False
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
False
End Select

End Sub

Hth,
Merjet



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

On Mar 8, 4:13 pm, "merjet" wrote:
The following is for 2 Option Buttons (#2 & #3) in Group1 and 4 in
Group2 (#5-#8), but it should be easy to adapt. Button5's value is set
to 1 in case one of the Buttons to be disabled is checked. It won't
"grey out", but it will disable.

Public Sub ControlOptions()
Dim ID As String
Dim OptBtn As Shape

ID = Application.Caller
Set OptBtn = ActiveSheet.Shapes(ID)

Select Case OptBtn.Name
Case Is = "Option Button 2"
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
True
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
True
Case Is = "Option Button 3"
ActiveSheet.OptionButtons("Option Button 5").Value = 1
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
False
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
False
End Select

End Sub

Hth,
Merjet


Hi, Merjet:

Thank you so much for your time and efforts in helping me out! I put
your code under a "Module1". However, when I press Alt + Q and click
OptionButton3 in groupbox1, I can still click any one of
OptionButton5, OptionButton6, OptionButton7, and OptionButton8. It
looks like the code doesn't work. Please correct me if I am wrong.

I look forward to hearing from you soon!

Thanks again,

George



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

My code does not depend on pressing Alt+Q. Both Option Button 2 and
Option Button 3 are linked to the macro ControlOptions, so it executes
automatically if either Button is clicked. I can send the Excel file
to your e-mail address if you want.

Merjet


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

On Mar 8, 7:55 pm, "merjet" wrote:
My code does not depend on pressing Alt+Q. Both Option Button 2 and
Option Button 3 are linked to the macro ControlOptions, so it executes
automatically if either Button is clicked. I can send the Excel file
to your e-mail address if you want.

Merjet


Hi, Merjet:

From what you said, you are pretty sure that your code is working

properly. If you don't mind, please send your excel file to me. My e-
mail address is

I am looking forward to hearing from you soon!

Thanks again for your time and efforts in helping me out!

Sincerely,

George

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default need help on how to grey out one option button in one group box based on the selection of another option button in another group box

I found the way, but it took a while. Programming for Forms Toolbar
controls is much harder than for Control Toolbox Toolbar controls.
Enhanced code below.

Hth,
Merjet


Public Sub ControlOptions()
Dim ID As String
Dim OptBtn As Shape

ID = Application.Caller
Set OptBtn = ActiveSheet.Shapes(ID)

Select Case OptBtn.Name
Case Is = "Option Button 2"
'enable any disabled option buttons and make them white
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
True
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
True
ActiveSheet.OptionButtons("Option Button
6").ShapeRange.Fill.Visible = msoFalse
ActiveSheet.OptionButtons("Option Button
7").ShapeRange.Fill.Visible = msoFalse
Case Is = "Option Button 3"
'make sure option buttons to be disabled are not selected
ActiveSheet.OptionButtons("Option Button 5").Value = 1
'disable some option buttons and make them grey
ActiveSheet.Shapes("Option Button 6").ControlFormat.Enabled =
False
ActiveSheet.Shapes("Option Button 7").ControlFormat.Enabled =
False
'make the disabled option buttons grey
With ActiveSheet.OptionButtons("Option Button
6").ShapeRange.Fill
.Visible = msoTrue
.Transparency = 0.7 'lower is darker
.ForeColor.SchemeColor = 22
End With
With ActiveSheet.OptionButtons("Option Button
7").ShapeRange.Fill
.Visible = msoTrue
.Transparency = 0.7 'lower is darker
.ForeColor.SchemeColor = 22
End With
End Select

End Sub


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
Testing a group of option buttons for a selection. Amber_D_Laws[_71_] Excel Programming 1 February 15th 06 09:17 PM
Option buttons: How to get the selected option from a group? naddad Excel Programming 5 December 21st 05 05:09 PM
Option button group name Chad Excel Programming 4 August 26th 05 04:08 PM
Insert Option Button based on value pjw23[_4_] Excel Programming 3 October 26th 04 04:03 PM
Insert Option Button based on value pjw23[_5_] Excel Programming 0 October 26th 04 03:33 PM


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