Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Mutually Exclusive Option Boxes

I put a couple of optionbuttons from the control toolbox toolbar on my test
worksheet.

I added the code to the worksheet's module.

The code worked fine when I clicked OptionButton1.

But the only time excel sees you click on optionbutton1 is when you change its
value from off to on. You actually turn it off by selecting (clicking on) a
different optionbutton.

So have one procedure for each button:

Option Explicit
Private Sub OptionButton1_Click()
If OptionButton1.Value = True Then
With Me
.Unprotect
With Me.Range("I22:K35")
.Locked = False
.FormulaHidden = False
.Interior.ColorIndex = 39
End With
.Protect
End With
End If
End Sub
Private Sub OptionButton2_Click()
If OptionButton2.Value = True Then
With Me
.Unprotect
With Me.Range("I22:K35")
.Locked = True
.FormulaHidden = True
.Interior.ColorIndex = xlNone
End With
.Protect
End With
End If
End Sub

I don't know what your 3rd optionbutton does.

5elpep wrote:

Cheers Dave & Fred,

I am now trying to control protection on part of the worksheet via one
of my option buttons.
Basically when the option is checked the cells should be unprotected
and when I select one of the other option buttons in the group the
cells should be protected again.

I am using the below code but it oesn't seem to work. It unprotects
and protects the sheet fine but it won't format the cells as
required. Any pointers would be much appreciated.

Private Sub OptionButton1_Click()

If OptionButton1.Value = True Then

ActiveSheet.Unprotect
Range("I22:K35").Select
Selection.Locked = False
Selection.FormulaHidden = False
Selection.Interior.ColorIndex = 39
ActiveSheet.Protect

Else

ActiveSheet.Unprotect
Range("I22:K35").Select
Selection.Locked = True
Selection.FormulaHidden = True
Selection.Interior.ColorIndex = xlNone
ActiveSheet.Protect

End If
End Sub


--

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
Mutually exclusive cells - Excel 2003 Kathleen Excel Worksheet Functions 2 July 18th 08 03:44 PM
Is there a way to make 6 columns mutually exclusive? Sandie D Excel Worksheet Functions 1 November 20th 06 10:09 PM
2 IF Statements not mutually exclusive Bev Excel Discussion (Misc queries) 2 August 24th 06 05:23 AM
Making checkboxes mutually exclusive instructorjml Excel Discussion (Misc queries) 3 April 6th 06 06:45 AM
Mutually exclusive values scantor145[_23_] Excel Programming 1 March 31st 06 04:02 PM


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