title: How to ask for Checkbox (True/False) in Macro using If-function
body: <p>How can I hide/show columns and rows in another sheet ("Project Plan") within the same workbook using a checkbox? If the checkbox is checked, they should not be hidden. If the checkbox is not checked, they should be hidden. The checkboxes are in an own sheet ("Guidelines").
  I tried the following but get the error "Run time error '424': Object required'"</p>
  
  <pre><code>Sub Team_Availability_Click()
  
  Dim rng As Range
  
  Set rng = ThisWorkbook.Sheets("Project Plan").Rows("5:8")
  
     If Team_Availability.Value = False Then
      rng.Hidden = True
  
     ElseIf Team_Availability.Value = True Then
      rng.Hidden = False    
  
  End If
  End Sub
  </code></pre>
  
  <p>Alternatively, I tried out this way, found in a similar question using some kind of object:</p>
  
  <h2><a href="https://stackoverflow.com/questions/11741836/checking-if-a-worksheet-based-checkbox-is-checked">Checking if a worksheet-based checkbox is checked</a></h2>
  
  <pre><code>Sub Team_Availability_Click()
  
  Dim rng As Range
  Set rng = ThisWorkbook.Sheets("Project Plan").Rows("5:8")
  
   If ThisWorkbook.Worksheets("Guidelines").Shapes("Team_Availability").OLEFormat.Object.Value = 0 Then
      rng.Hidden = True
  
   ElseIf ThisWorkbook.Worksheets("Guidelines").OLEFormat.Object.Value = 1 Then
      rng.Hidden = False
  
  End If
  End Sub
  </code></pre>
  
  <hr>
  
  <p>Here I get the error </p>
  
  <blockquote>
    <p>The Item with the specified name wasn't found.</p>
  </blockquote>
  
  <p>I did not introduce the dim/set I guess. Now, this is the newest version:</p>
  
  <p>Now I get the error in in line <code>Set cb = ActiveSheet...</code> saying </p>
  
  <blockquote>
    <p>The item with the specified name wasn't found.</p>
  </blockquote>
  
  <pre><code>Sub Team_Availability_Click()
  
  Dim cb As Shape
  Dim rng As Range
  
  Set cb = ThisWorkbook.Sheets("Guidelines").Shapes("Team_Availability")
  Set rng = ThisWorkbook.Sheets("Project Plan").Rows("5:8")
  
   If ThisWorkbook.Sheets("Guidelines").Shapes("Team_Availability").OLEFormat.Object.Value = -4146 Then
      rng.Hidden = True
  
   ElseIf ThisWorkbook.Sheets("Guidelines").Shapes("Team_Availability").OLEFormat.Object.Value = 1 Then
      rng.Hidden = False
  
   End If
  
  End Sub
  </code></pre>