title: VBA Loop across one row to find a value that contains a cell and delete columns before that column
body: <p>I need to check each cell in row 7 starting from C7 (C7, D7, E7, etc) and find a cell with a string value that contains a certain date (for example, "9/30/2017" in string "6/30/2017 to 9/30/2017") and delete ALL columns from column C to whatever column that the cell is in. How would I do this with VBA code? I am new to VBA and have tried everything that I could find. Thankful for any suggestions</p>
  
  <p>My code:</p>
  
  <pre><code>Sub DeleteUnnecessaryColumns(specifiedWorksheet) 
  
  Dim lastCol As Long 
  lastCol = Cells.Find(What:="*", After:=[C1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column 
  
  For i = 1 To lastCol 
      If InStr(Cells(7, 0), specifiedDate, vbTextCompare) = 0 Then 
          Columns(i).Delete 
      End If 
  Next i 
  
  End Sub
  </code></pre>