So you suggest changing all the checkbox names to an actual name. i.e instead of CheckBox1_Click() to BattDis_Click()
Not necessarily, if they are OK the way they are leave them alone. Hind site is 20-20. Naming them as they are created is much easier than trying to change them after the fact.
They would still have to be consistently named. If you were to copy and paste a CheckBox1 to another form that already has check boxes (that are also default names) then this check box would be automatically renamed to CheckBox next number for that form. I'd probably change the names to CkBox1, CkBox2, etc. so Excel doesn't change the names.
That would also require renaming all the CheckBoxX_Click procedures and changing the part of the macro that gets the check box number from the name. (which is the next explanation)
Is there anyway you can help me understand this part of the code a little more. I have never worked with Mid, Instr and Left before.In this part of the code what is 9 referring too? and the 1?
The 1 in .cells(i, 1) is the column number, could have used "A"
Mid and 9 in Mid(ctrl.Name, 9). This is extracting the number part of the control name.
Mid gets the middle characters starting at the 9th character. Because there is no argument for how many to get it takes them all from the 9th to the end.
Left and Instr are used to extract the left portion of the cell value up to the equal sign.
Instr gets the position of the equal sign and Left uses that as the number of characters to extract.
The value of a checkbox is True or False. Based on that we are adding ON or OFF after the equal sign in the cell that has the same row number as the check box number. We are cycling through all the checkboxes and writing each cell every time.
Wow... not sure I can make sense of that, with a little luck maybe you can decipher it.
NoSparks