Excel VBA activate objects if checkbox ticked <p>I have got a piece of code that works which changes a input field from disabled to enabled and changes the colour from gray to white if the corresponsding checkbox is ticked.</p> <p>Is there a way to loop this or call it for all checkboxes &amp; input fields without having a seperate piece of code for each pair?</p> <p>The code I have is:</p> <pre><code>Private Sub CheckBox1_Click() If CheckBox1.Value = True Then tb01.Enabled = True tb01.BackColor = vbWhite Else: tb01.Enabled = False tb01.BackColor = vb3DLight End If End Sub Private Sub CheckBox2_Click() If CheckBox2.Value = True Then tb02.Enabled = True tb02.BackColor = vbWhite Else: tb02.Enabled = False tb02.BackColor = vb3DLight End If End Sub </code></pre> <p>edit: This code is in a UserForm</p>