My user form will have a series of Check Box Form Controls. They will be used for displaying results from a matrix (array) on a separate worksheet. The user will make a selection from a validated list. The list is a document category. For each category, there are several associated departments that must sign off on the document. The user must be able to select additional departments, but may not deselect any pre-selected departments. The pre-selected items will be disabled via VBA.
I am using conditional formatting to indicate one of three states each checkbox may have. I am not using the checkbox's caption, but instead am using the adjacent cell for that purpose. Each checkbox will have an addditonal cell used to store the Enabled state of the checkbox.
The three states are as follows:
Unselected (tan background), Checkbox's linked cell value (G2) is FALSE, Enabled State cell value (H2) is "".
Pre-selected (purple background), Checkbox's linked cell value (G2) is TRUE, Enabled State cell value (H2) is FALSE.
User-selected (green background), Checkbox's linked cell value (G2) is TRUE, Enabled State cell value (H2) is "".
For testing purposes only, I have added two command buttons. Button3 selects the checkbox and disables it. Button4 deselects and re-enables. The code and conditional formatting work as intended.
So my question is, What is the best way of looping through a series of 20-25 of these checkboxes? As the selection changes in the validated list, so will the associated checkboxes that must be pre-selected and disabled, based on the values in the matrix. I will also need to loop through the selected items and transfer the list to a report. I have an example workbook with the matrix and a single checkbox, but am unable to post attachments.
Thanks!
I am using conditional formatting to indicate one of three states each checkbox may have. I am not using the checkbox's caption, but instead am using the adjacent cell for that purpose. Each checkbox will have an addditonal cell used to store the Enabled state of the checkbox.
The three states are as follows:
Unselected (tan background), Checkbox's linked cell value (G2) is FALSE, Enabled State cell value (H2) is "".
Pre-selected (purple background), Checkbox's linked cell value (G2) is TRUE, Enabled State cell value (H2) is FALSE.
User-selected (green background), Checkbox's linked cell value (G2) is TRUE, Enabled State cell value (H2) is "".
For testing purposes only, I have added two command buttons. Button3 selects the checkbox and disables it. Button4 deselects and re-enables. The code and conditional formatting work as intended.
Code:
Sub Button3_Click()
'Selects the checkbox
ActiveSheet.Range("G2") = True
'Disables the checkbox
Sheets("Sheet1").CheckBoxes("Check Box 1").Enabled = False
ActiveSheet.Range("H2") = False
End Sub
Sub Button4_Click()
'Deselects the checkbox
ActiveSheet.Range("G2") = False
'Re-enables the checkbox
Sheets("Sheet1").CheckBoxes("Check Box 1").Enabled = True
ActiveSheet.Range("H2") = ""
End Sub
So my question is, What is the best way of looping through a series of 20-25 of these checkboxes? As the selection changes in the validated list, so will the associated checkboxes that must be pre-selected and disabled, based on the values in the matrix. I will also need to loop through the selected items and transfer the list to a report. I have an example workbook with the matrix and a single checkbox, but am unable to post attachments.
Thanks!