title: 'Variable not defined' error when changing value of checkbox.
body: <p>I have a simple Sub to set a checkbox (placed on a worksheet) depending on whether or not a Worksheet is protected.</p>
  
  <p><code>chkToggleProtect</code> absolutely exists, by I'm getting a compile error on either of the lines where I reference it -</p>
  
  <blockquote>
    <p>Variable not defined</p>
  </blockquote>
  
  <p>Any ideas what I'm doing wrong?</p>
  
  <pre><code>Private Sub SetToggleProtect(ByRef isprotected As Boolean)
  
      If isprotected Then
          chkToggleProtect.Checked = True
      Else
          chkToggleProtect.Checked = False
      End If
  
  End Sub
  </code></pre>