title: Excel changes based on cell contents
body: <p>I am trying to create a script that will apply to an Excel script for an SSIS package that will change column visibility based on a cell's contents.</p>
  
  <p>Basically I have a column that will contain the name of a report.  This report will either contain the word "MID" or "END", which determines if it is a mid month or a month end report.  Right now, I have the script run through the contents of the cells in that column and should be making cells visible or not, but I believe the issue is that the <code>If Else</code> isn't applying before the integer I am using is increased, so it runs through the whole list looking if it is the first condition of the <code>If</code> statement, but doesn't loop back to the beginning for the <code>Else</code> statement.  </p>
  
  <p>If there is a better way to make changes based on a cell's contents in a range of cells, please let me know as this will be used extensively.</p>
  
  <p>Here's the code I have currently:</p>
  
  <pre><code>'Mid Month/Month End Changes
  ReportRange = .Range("B2", "B" &amp; lastrow)
  k = 0
  For k = 0 To ReportRange.Rows.Count - 1
      ReportCell = .Cells(2 + k, 2)
      Report = ReportCell.Value
      MidHrsCell = ReportCell.Offset(, 5)
      EndHrsCell = ReportCell.Offset(, 6)
  
      For Each Cell In ReportRange
          If InStr(Report, "MID") &gt; 0 Then
              EndHrsCell.EntireColumn.Hidden = True
          Else 
              MidHrsCell.EntireColumn.Hidden = True
          End If
      Next
  Next
  </code></pre>