title: Hide columns in one sheet based on a cell from another sheet - Excel VBA
body: <p>Inside an excel workbook I have sheet1 and sheet2. </p>
  
  <p>In <strong>Sheet1</strong> I have a cell that changes dynamically (cell A1).
  In <strong>Sheet2</strong> I have a cell (B1) that copies the value from cell A1 from Sheet1.
  On <strong>Sheet 2</strong> cells will hide when the value in B1 is 0.</p>
  
  <p><a href="https://i.stack.imgur.com/rPSdh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rPSdh.png" alt="link image"></a></p>
  
  <p>Here is the VBA code from sheet2</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
      If Range("B1").Value = "0" Then
          Columns("E:I").EntireColumn.Hidden = True
      Else
          Columns("E:I").EntireColumn.Hidden = False
      End If
  
  End Sub
  </code></pre>
  
  <p>The thing is that when I change the value on <strong>Sheet1</strong> nothing happens on <strong>Sheet2</strong>, and I don´t know why.</p>