VBA to hide and unhide columns based on their dynamic first row value
<p>I have an Excel workbook with 2 sheets: <code>summary</code> and <code>ClickHide</code>.</p>

<ul>
<li><p><code>Summary Sheet</code> contains multiple checkbox forms.  When the checkbox is checked, they return a <code>TRUE</code> or <code>FALSE</code> value in the <code>ClickHide Sheet</code>, all in <code>ROW A</code>.</p></li>
<li><p><code>ClickHideSheet</code>: Next to these values in <code>A2:A20</code>, I attribute a "0" or "1" value to the <code>TRUE or FALSE</code> result.  These results go horizontally in  range <code>B2:BZ45</code>. On <code>ClickHide Row 1</code>, I have formulae to get a result on top of each column.</p></li>
<li><p>In <code>Summary B1:BZ1</code> I have copied links to the cells in <code>ClickHide A1:BZ1</code>.</p></li>
</ul>

<p><strong>My question</strong>:  </p>

<blockquote>
  <p>I intend to make the columns in <code>Summary</code> to automatically hide when the value in their own row is <strong>not</strong> 0.  (if B1 is not 0, hide column B, otherwise unhide).  The user will interact with the checkboxes, so the macro needs to be triggered every time a checkbox is modified.</p>
</blockquote>

<p>I have found code snippets out there, but none of them seem to work.  I'm really bad at VBA, so it could be a simple edit that I'm missing.</p>

<p>I've tried both of these, with no success. Have a look <a href="https://forum.openoffice.org/en/forum/viewtopic.php?f=20&amp;t=79218" rel="nofollow">the following reference</a>.</p>

<pre><code>    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim i As Integer
    For i = 2 To 80
        Cells(1, i).EntireColumn.Hidden = Cells(2, i) = 0
    Next
End Sub
</code></pre>

<p>This next one I don't really know if it's a VBA code or not.</p>

<pre><code>oSheets = ThisComponent.getSheets()
oSheet1 = oSheets.getByName("Sheet1")
oColumns = oSheet1.getColumns()
for i = 0 to 25
   oCol = oColumns.getByIndex(i)
   oCell = oSheet1.getCellByPosition(i,0) 'First row has index 0
   If oCell.Value = 0 Then
      oCol.isVisible = False
   Else
      oCol.isVisible = True
   End If
next i
</code></pre>

<p>I don't know how to embed a spreadsheet in here, so here are pictures of both sheets, simplified to show an example.</p>

<ul>
<li><a href="http://i.stack.imgur.com/pHa9u.png" rel="nofollow">Summary Sheet</a></li>
<li><a href="http://i.stack.imgur.com/0Cjqt.png" rel="nofollow">ClickHide Sheet</a></li>
</ul>

<p>Thanks in advance for any help you can provide.</p>