title: Excel 2010: Macro for hidden column groups
body: <p>VBA is not my particular strength, but here we go:</p>
  
  <p>I would like to trigger a macro once a group of columns is hidden or shown. How can I archive this?</p>
  
  <hr>
  
  <h1>The results of my previous research</h1>
  
  <p>The only good hint about this I could find is <a href="http://social.msdn.microsoft.com/Forums/office/en-US/a5d44c36-1953-49b5-9f22-e80fa06a1175/is-there-any-way-to-trigger-an-event-when-a-column-is-hidden" rel="nofollow">this</a> discussion at MSDN. Here, a solution is using the following way is drafted:</p>
  
  <p>From the root dir of the xlsx file create a file <code>customUI\customUI.xml</code> with the content </p>
  
  <pre><code>&lt;customUI  xmlns="http://schemas.microsoft.com/office/2006/01/customui" &gt;
      &lt;commands &gt;
          &lt;command 
              idMso="ColumnsHide"
              onAction="ColumnHide_onAction"/&gt;
          &lt;command 
              idMso="ColumnsUnhide"
              onAction="ColumnUnhide_onAction"/&gt;
      &lt;/commands &gt;
  &lt;/customUI &gt;
  </code></pre>
  
  <p>and add </p>
  
  <pre><code>&lt;Relationship Id="edTAB" Type="http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target="customUI/customUI.xml" /&gt;
  </code></pre>
  
  <p>to the <code>_rels\_rels.xml</code>. (All this probably is much easier using Visual Studio, but I have no access to such sophisticated tools in the microsoft world...) Now, the macro can be used the following way:</p>
  
  <pre><code>Public Sub ColumnHide_onAction(control As IRibbonControl, ByRef cancelDefault)
  '
  ' Code for onAction callback. Ribbon control command
  '
      MsgBox "Ribbon Column Hide"
      cancelDefault = False
  
  End Sub
  Public Sub ColumnUnhide_onAction(control As IRibbonControl, ByRef cancelDefault)
  '
  ' Code for onAction callback. Ribbon control command
  '
      MsgBox "Ribbon Column Unhide"
      cancelDefault = False
  End Sub
  </code></pre>
  
  <p>This approach perfectly catches hiding and unhiding of columns, but not hiding and unhiding of groups. So, close, but not quite there. </p>
  
  <p>Downloading the possible <code>idMso</code> values from <a href="http://www.microsoft.com/en-us/download/details.aspx?id=3582" rel="nofollow">here</a>, I got notice of the <code>GroupViewShowHide</code> control. Using this the same way as <code>ColumnsHide</code> or <code>ColumnsUnhide</code> does not archive the desired result, though.</p>
  
  <p>Any ideas?</p>