I have searched my issue with no success so far. Hoping someone can point me in the right direction. I have a file with many checkboxes. For example: checkbox1, checkbox2, etc. I would like to check any checkbox and uncheck others at the same time. If checkbox1 is already checked and I click on checkbox2, it will then uncheck checkbox1 and check checkbox2.
Code:
Option Explicit
Private Sub CheckBox1_Click()
'Turn off screen updating
Application.ScreenUpdating = False
If CheckBox1.Value = True Then
CheckBox2.Value = 0
CheckBox2.Enabled = True
CheckBox3.Value = False
CheckBox3.Enabled = True
CheckBox4.Value = False
CheckBox4.Enabled = True
Worksheets("Score").Activate
'Unprotect the "Score" worksheet
ActiveSheet.Unprotect Password:=""
Sheet3.Range("B8").Value = 10 'Checked
Sheet3.Range("D8").Value = "" 'Unchecked
Sheet3.Range("F8").Value = "" 'Unchecked
Sheet3.Range("H8").Value = "" 'Unchecked
'Protects the "Score" worksheet
ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
Worksheets("Request").Activate
Else
CheckBox1.Value = False
CheckBox2.Value = False
CheckBox2.Enabled = True
CheckBox3.Value = False
CheckBox3.Enabled = True
CheckBox4.Value = False
CheckBox4.Enabled = True
Worksheets("Score").Activate
'Unprotect the "Score" worksheet
ActiveSheet.Unprotect Password:=""
Sheet3.Range("B8").Value = "" 'Unchecked
'Protects the "Score" worksheet
ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
Worksheets("Request").Activate
End If
'Turn on screen updating
Application.ScreenUpdating = True
End Sub
Private Sub CheckBox2_Click()
'Turn off screen updating
Application.ScreenUpdating = False
If CheckBox2.Value = True Then
CheckBox1.Value = 0
CheckBox1.Enabled = True
CheckBox3.Value = False
CheckBox3.Enabled = True
CheckBox4.Value = False
CheckBox4.Enabled = True
Worksheets("Score").Activate
'Unprotect the "Score" worksheet
ActiveSheet.Unprotect Password:=""
Sheet3.Range("D8").Value = 60 'Checked
Sheet3.Range("B8").Value = "" 'Unchecked
Sheet3.Range("F8").Value = "" 'Unchecked
Sheet3.Range("H8").Value = "" 'Unchecked
'Protects the "Score" worksheet
ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
Worksheets("Request").Activate
Else
CheckBox2.Value = False
CheckBox1.Value = False
CheckBox1.Enabled = True
CheckBox3.Value = False
CheckBox3.Enabled = True
CheckBox4.Value = False
CheckBox4.Enabled = True
Worksheets("Score").Activate
'Unprotect the "Score" worksheet
ActiveSheet.Unprotect Password:=""
Sheet3.Range("D8").Value = "" 'Unchecked
'Protects the "Score" worksheet
ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True
Worksheets("Request").Activate
End If
'Turn on screen updating
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: