title: Expand and collapse rows using Excel VBA
body: <p>I'm building a form with different sections. I do not want to use either a Command button or a Toggle button (their look is ugly) and since this is for clients I want it to be user friendly. Anyway so basically I want to build a macro that when they click on the shape it will collapse the unnecessary rows and expand the right rows. </p>
  
  <p>So far this is what I was able to find... but it only applies to a command button.</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  With Me.CommandButton1
          If .Caption = "Initial Request" Then
              .Caption = "Hide Rows"
              Rows("12:20").Hidden = False
          Else
              .Caption = "Initial Request"
              Rows("12:200").Hidden = True
          End If
      End With
  
  End Sub
  </code></pre>
  
  <p>This works perfectly... but, is there a way to transform this so that it can be added to a Module and therefore assigned to a shape?</p>
  
  <p>Thank you very much for your help</p>