title: How To Use Private Sub Checkbox Name variable in Code?
body: <p>I have an ActiveX Checkbox in Excel that when clicked will change a cell value to add 1.</p>
  
  <p>I need to repeat this VBA code when I use the same Checkbox in a different Cell Value, which I need to repeat many times.</p>
  
  <p>How do I reference the automatically generated checkbox name variable in the VBA code for each new cell value?</p>
  
  <p>This is for a Excel spreadsheet that I use to update a database when new reports are turned in with "checked" information on it. </p>
  
  <pre><code>Private Sub CheckBox21_Click()
  
  Range("L2").Activate
  
      'Don't want to type CheckBoxXX each time, just find way to automatically reference?'
      If CheckBox21.Value = True Then
          ActiveCell.Value = ActiveCell.Value + 1
      Else
          If ActiveCell.Value &gt; 0 Then
          ActiveCell.Value = ActiveCell.Value - 1
      Else
          End If
      End If
  
  
  _____________________________________________________________________________
  'Next line'
  
  Private Sub CheckBox22_Click()
  
  Range("L2").Activate
  
      If CheckBox22.Value = True Then
          ActiveCell.Value = ActiveCell.Value + 1
      Else
          If ActiveCell.Value &gt; 0 Then
          ActiveCell.Value = ActiveCell.Value - 1
      Else
          End If
      End If
  
  End Sub
  </code></pre>
  
  <p>I don't want to type <code>CheckBoxXX</code> each time, just to automatically reference?</p>