I have a spreadsheet where I am simply assigning the value of a CheckBox to a Range of Cells so later I can hide all that have a "False" value assigned to them. Currently I have the code under an AcceptButton but wondered if there is a cleaner way to get the same result with less code. One of my colleagues has told me that he believes I can do this by placing code in each CheckBox and under the Accept Button by using a sub routine. Here is a sample of the code currently only in the AcceptButton:
Public Sub AcceptButton_Click()
'Checkbox 1
If CheckBox1.Value = True Then
range("J9:J15").Value = "True"
End If
If CheckBox1.Value = False Then
range("J9:J15").Value = "False"
End If
'CheckBox 2
If CheckBox2.Value = True Then
range("J16:J22").Value = "True"
End If
If CheckBox2.Value = False Then
range("J16:J22").Value = "False"
End If
'CheckBox 3
If CheckBox3.Value = True Then
range("J37:J52").Value = "True"
End If
If CheckBox3.Value = False Then
range("J37:J52").Value = "False"
End If
'CheckBox 4
If CheckBox4.Value = True Then
range("J191:J206").Value = "True"
End If
If CheckBox4.Value = False Then
range("J191:J206").Value = "False"
End If
Me.Hide
End Sub
Bookmarks