Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Conditionally Disabling Optionbuttons

I have two option buttons (from the Control Toolbox in Excel 2003) named
"OptionButton18" and "OptionButton19", both of which have the GroupName
"nameWallTile."

OptionButton18 also has what I am considering a subgroup of 3 option
buttons, all of which have the GroupName "nameWallTileBKSP"

I would like the group "nameWallTileBKSP" of OptionButton18 to be disabled
when OptionButton19 is selected.

Any suggestions? I'm not very familiar with VB, but am not afraid of
learning something new, especially about Excel!

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Conditionally Disabling Optionbuttons

You could just use the names of the 3 "sub-optionbuttons" and disable them. But
if you add more optionbuttons to that group "nameWallTileBKSP", then you'll have
to update the code for those names.

Another way is to loop through all the OLEobjects on the sheet and look at the
groupname and decide to enable/disable it based on the "checkedness" of
optionbutton19.

This goes under the worksheet module that owns those optionbuttons:

Option Explicit
Private Sub OptionButton18_Click()
Call CheckSubGroup
End Sub
Private Sub OptionButton19_Click()
Call CheckSubGroup
End Sub
Sub CheckSubGroup()

Dim OLEObj As OLEObject
Dim myEnabled As Boolean

myEnabled = Not (Me.OptionButton19.Value)

For Each OLEObj In Me.OLEObjects
If TypeOf OLEObj.Object Is MSForms.OptionButton Then
If LCase(OLEObj.Object.GroupName) = LCase("nameWallTileBKSP") Then
OLEObj.Enabled = myEnabled
'OLEObj.Object.Value = False
End If
End If
Next OLEObj

End Sub

kgriba wrote:

I have two option buttons (from the Control Toolbox in Excel 2003) named
"OptionButton18" and "OptionButton19", both of which have the GroupName
"nameWallTile."

OptionButton18 also has what I am considering a subgroup of 3 option
buttons, all of which have the GroupName "nameWallTileBKSP"

I would like the group "nameWallTileBKSP" of OptionButton18 to be disabled
when OptionButton19 is selected.

Any suggestions? I'm not very familiar with VB, but am not afraid of
learning something new, especially about Excel!

Thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Conditionally Disabling Optionbuttons

Hi Dave... thanks... gave that a try and probably due to my lack of
understanding, got an error message popup, "Invalid Use of the Me Keyword."
I've learned in the editor that it's likely having to do with my incorrect
placement of your code into "Module1".

I wasn't really sure what "This goes under the worksheet module that owns
those optionbuttons:" meant, so I guessed. I copy-pasted your code into the
only module I can see in the editor, that would be "Module1".

Do I need to create a module with a name associated with the GroupNames or
OptionButton names?

Thanks again,
Kristine



"Dave Peterson" wrote:

You could just use the names of the 3 "sub-optionbuttons" and disable them. But
if you add more optionbuttons to that group "nameWallTileBKSP", then you'll have
to update the code for those names.

Another way is to loop through all the OLEobjects on the sheet and look at the
groupname and decide to enable/disable it based on the "checkedness" of
optionbutton19.

This goes under the worksheet module that owns those optionbuttons:

Option Explicit
Private Sub OptionButton18_Click()
Call CheckSubGroup
End Sub
Private Sub OptionButton19_Click()
Call CheckSubGroup
End Sub
Sub CheckSubGroup()

Dim OLEObj As OLEObject
Dim myEnabled As Boolean

myEnabled = Not (Me.OptionButton19.Value)

For Each OLEObj In Me.OLEObjects
If TypeOf OLEObj.Object Is MSForms.OptionButton Then
If LCase(OLEObj.Object.GroupName) = LCase("nameWallTileBKSP") Then
OLEObj.Enabled = myEnabled
'OLEObj.Object.Value = False
End If
End If
Next OLEObj

End Sub

kgriba wrote:

I have two option buttons (from the Control Toolbox in Excel 2003) named
"OptionButton18" and "OptionButton19", both of which have the GroupName
"nameWallTile."

OptionButton18 also has what I am considering a subgroup of 3 option
buttons, all of which have the GroupName "nameWallTileBKSP"

I would like the group "nameWallTileBKSP" of OptionButton18 to be disabled
when OptionButton19 is selected.

Any suggestions? I'm not very familiar with VB, but am not afraid of
learning something new, especially about Excel!

Thanks!


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Conditionally Disabling Optionbuttons

Select the worksheet with the optionbuttons.

Rightclick on the worksheet tab and select View Code.

Paste the code here.

And clean up that code you put in a general module. It doesn't belong there.



kgriba wrote:

Hi Dave... thanks... gave that a try and probably due to my lack of
understanding, got an error message popup, "Invalid Use of the Me Keyword."
I've learned in the editor that it's likely having to do with my incorrect
placement of your code into "Module1".

I wasn't really sure what "This goes under the worksheet module that owns
those optionbuttons:" meant, so I guessed. I copy-pasted your code into the
only module I can see in the editor, that would be "Module1".

Do I need to create a module with a name associated with the GroupNames or
OptionButton names?

Thanks again,
Kristine

"Dave Peterson" wrote:

You could just use the names of the 3 "sub-optionbuttons" and disable them. But
if you add more optionbuttons to that group "nameWallTileBKSP", then you'll have
to update the code for those names.

Another way is to loop through all the OLEobjects on the sheet and look at the
groupname and decide to enable/disable it based on the "checkedness" of
optionbutton19.

This goes under the worksheet module that owns those optionbuttons:

Option Explicit
Private Sub OptionButton18_Click()
Call CheckSubGroup
End Sub
Private Sub OptionButton19_Click()
Call CheckSubGroup
End Sub
Sub CheckSubGroup()

Dim OLEObj As OLEObject
Dim myEnabled As Boolean

myEnabled = Not (Me.OptionButton19.Value)

For Each OLEObj In Me.OLEObjects
If TypeOf OLEObj.Object Is MSForms.OptionButton Then
If LCase(OLEObj.Object.GroupName) = LCase("nameWallTileBKSP") Then
OLEObj.Enabled = myEnabled
'OLEObj.Object.Value = False
End If
End If
Next OLEObj

End Sub

kgriba wrote:

I have two option buttons (from the Control Toolbox in Excel 2003) named
"OptionButton18" and "OptionButton19", both of which have the GroupName
"nameWallTile."

OptionButton18 also has what I am considering a subgroup of 3 option
buttons, all of which have the GroupName "nameWallTileBKSP"

I would like the group "nameWallTileBKSP" of OptionButton18 to be disabled
when OptionButton19 is selected.

Any suggestions? I'm not very familiar with VB, but am not afraid of
learning something new, especially about Excel!

Thanks!


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Conditionally Disabling Optionbuttons

Brilliant! Worked like a charm! There's no way I would have figured that one
out on my own. And, I've cleaned up the general module as well (actually did
that after the error message pop-up.)

Thanks again,
Kristine

"Dave Peterson" wrote:

Select the worksheet with the optionbuttons.

Rightclick on the worksheet tab and select View Code.

Paste the code here.

And clean up that code you put in a general module. It doesn't belong there.



kgriba wrote:

Hi Dave... thanks... gave that a try and probably due to my lack of
understanding, got an error message popup, "Invalid Use of the Me Keyword."
I've learned in the editor that it's likely having to do with my incorrect
placement of your code into "Module1".

I wasn't really sure what "This goes under the worksheet module that owns
those optionbuttons:" meant, so I guessed. I copy-pasted your code into the
only module I can see in the editor, that would be "Module1".

Do I need to create a module with a name associated with the GroupNames or
OptionButton names?

Thanks again,
Kristine

"Dave Peterson" wrote:

You could just use the names of the 3 "sub-optionbuttons" and disable them. But
if you add more optionbuttons to that group "nameWallTileBKSP", then you'll have
to update the code for those names.

Another way is to loop through all the OLEobjects on the sheet and look at the
groupname and decide to enable/disable it based on the "checkedness" of
optionbutton19.

This goes under the worksheet module that owns those optionbuttons:

Option Explicit
Private Sub OptionButton18_Click()
Call CheckSubGroup
End Sub
Private Sub OptionButton19_Click()
Call CheckSubGroup
End Sub
Sub CheckSubGroup()

Dim OLEObj As OLEObject
Dim myEnabled As Boolean

myEnabled = Not (Me.OptionButton19.Value)

For Each OLEObj In Me.OLEObjects
If TypeOf OLEObj.Object Is MSForms.OptionButton Then
If LCase(OLEObj.Object.GroupName) = LCase("nameWallTileBKSP") Then
OLEObj.Enabled = myEnabled
'OLEObj.Object.Value = False
End If
End If
Next OLEObj

End Sub

kgriba wrote:

I have two option buttons (from the Control Toolbox in Excel 2003) named
"OptionButton18" and "OptionButton19", both of which have the GroupName
"nameWallTile."

OptionButton18 also has what I am considering a subgroup of 3 option
buttons, all of which have the GroupName "nameWallTileBKSP"

I would like the group "nameWallTileBKSP" of OptionButton18 to be disabled
when OptionButton19 is selected.

Any suggestions? I'm not very familiar with VB, but am not afraid of
learning something new, especially about Excel!

Thanks!

--

Dave Peterson


--

Dave Peterson



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
Conditionally disabling formulas nebb[_3_] Excel Programming 0 October 26th 04 04:25 PM
Disabling a 'Group' of OptionButtons JimP Excel Programming 2 January 26th 04 02:48 AM
OptionButtons Paul Excel Programming 4 December 4th 03 04:12 PM
optionbuttons Phil Perry Excel Programming 1 July 10th 03 09:13 PM


All times are GMT +1. The time now is 05:09 PM.

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"