I have a spreadsheet with many checkboxes and a checkbox determines if a row is going to be used in some calculations. Some sections have many rows, and to make it easier to select many row at once, I though it would be a great idea to add a "select all" checkbox. My spreadsheet was "macro free" up until this point. To achieve this, I found myself diving into VBA and macros.
I found this section of code somebody else presented as a solution to somebody else asking how to make a "select all" checkbox, and it worked. I added "SS" in the name field of all the checkboxes I wanted included and used this code below:
Sub SSCheckBoxes()
Application.ScreenUpdating = False
'Using Form Checkbox so it is a Shape object
Dim cbShape As Shape
'If the word "SS" is found in the checkbox name then check the box.
For Each cbShape In ActiveSheet.Shapes
If InStr(1, cbShape.Name, "SS", vbTextCompare) > 0 Then cbShape.ControlFormat.Value = xlOn 'xlOff
Next cbShape
Application.ScreenUpdating = True
End Sub
The problem is, I want the "select all" to be conditional. The checkbox in each row has a cell 3 columns to the left of it referencing quantity. I only want the checkbox to get selected when the checkbox name has "SS" in it, AND the cell 3 columns to the left has a value greater than 0. I thought I could do this, but I have learned it is over my head.
Can anybody give me the correct addition to the code above to achieve what I am trying to do?
I found this section of code somebody else presented as a solution to somebody else asking how to make a "select all" checkbox, and it worked. I added "SS" in the name field of all the checkboxes I wanted included and used this code below:
Sub SSCheckBoxes()
Application.ScreenUpdating = False
'Using Form Checkbox so it is a Shape object
Dim cbShape As Shape
'If the word "SS" is found in the checkbox name then check the box.
For Each cbShape In ActiveSheet.Shapes
If InStr(1, cbShape.Name, "SS", vbTextCompare) > 0 Then cbShape.ControlFormat.Value = xlOn 'xlOff
Next cbShape
Application.ScreenUpdating = True
End Sub
The problem is, I want the "select all" to be conditional. The checkbox in each row has a cell 3 columns to the left of it referencing quantity. I only want the checkbox to get selected when the checkbox name has "SS" in it, AND the cell 3 columns to the left has a value greater than 0. I thought I could do this, but I have learned it is over my head.
Can anybody give me the correct addition to the code above to achieve what I am trying to do?