title: Excel vba looping through columns and hide based on cell value
body: <p>Between columns F and BM of the sheet, if any value within those columns is equal to "NULL" then don't hide, otherwise hide that column, the column before and column after. The loop should evaluate every other 3rd starting at column G and ending at column BM. </p>
  
  <p>For example, if column G contains the value "NULL" then do nothing and go to column J (three columns forward). If column J now has no cells with value NULL then hide that column, the column before (column I), and the column after (column K). </p>
  
  <p>This is what Im having trouble with. I am able to hide a column based on if the column contains the value NULL or not. </p>
  
  <p>This is the code variations that I have attempted. </p>
  
  <pre><code>Sub SuspenseReport()
  
  Dim allColumns As Range
  Dim cell As Range
  Dim col As Range
  Dim x As Integer
  Dim i As Integer
  Application.ScreenUpdating = False
  
  Set allColumns = Columns("C:E")
  allColumns.Hidden = True
  
  Set allColumns = Columns("BN:DY")
  allColumns.Hidden = True
  
  Set allColumns = Columns("EB:EU")
  allColumns.Hidden = True
  
  Dim rng1 As Range: Set rng1 = Application.Range("G2:BO8") 'maybe limit the range to just one column and range.offet at the end?
  
  
  For Each col In rng.Columns 
          If cell.Value = "NULL" Then
              cell.EntireColumn.Hidden = False
              GoTo ExitIfStat
  
           Else: cell.EntireColumn.Hidden = True
  
  
          End If
      Next col
  ExitIfStat:
  Next x
  'below is another variation I attempted but the for loop would iterate on cell not column 
  'Dim i As Integer
  'i = -1
  'For Each col In Range("G1:BO8")
     '     i = i + 1
       '   If i Mod 3 = 0 Then
        '      If col.Value = "NULL" Then
        '          col.EntireColumn.Hidden = False
  
       '      Else: col.EntireColumn.Hidden = True
                      'col.Offset(0, -1).EntireColumn.Hidden = True
                     'col.Offset(0, 1).EntireColumn.Hidden = True
  
         '    End If
  
  
  
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>