title: Excel VBA : cells change values depending on specific groups (expanded or collapsed)
body: <p>I'd like to modify values on specific cells depending on a specific group if it's expanded or collapsed.</p>
  <p>I found a way, but it's a manual way <a href="https://i.stack.imgur.com/lMzj8.png" rel="nofollow noreferrer">(image1</a> <a href="https://i.stack.imgur.com/NLmln.png" rel="nofollow noreferrer">image2)</a> (the macro needs to be launched on each run).</p>
  <p>Is there a way to use a function (i.e. <em>worksheet_change</em>), so that will be on real time ?</p>
  <p>P.S. Sorry for my bad English and be kind, I'm kinda new on VBA (first code).</p>
  <p>Thank you.</p>
  <pre><code>Private Sub groups()
  
      If Worksheets(&quot;Feuil1&quot;).Columns(&quot;F&quot;).ShowDetail = True Then
      Range(&quot;K2:K7&quot;).Value = &quot;YES&quot;
  
      Else
      Range(&quot;K2:K7&quot;).Value = &quot;NO&quot;
  
      End If
  
  End Sub
  </code></pre>