title: VBA to keep certain columns and remove all others
body: <p>As topic says I have a vba code which does the job: remove all columns of sheet "incidents" and keep only the columns with names "Status", "Name" and "Age"</p>
  
  <p>But for some reason, after a few thousand rows, it does not work properly and removes the data/cells of that columns that is keeping , and also works quite slow.</p>
  
  <p>There is any other way to do this? More efective? At least to not remove any cell of that columns which must remain in the sheet.</p>
  
  <p>Thanks in advance (code below).</p>
  
  <pre><code>Sub Cleanup_report2()
      Dim currentColumn As Integer
      Dim columnHeading As String
  
      For currentColumn = Worksheets("Incidents").UsedRange.Columns.CounT To 1 Step -1
  
          columnHeading = Worksheets("Incidents).UsedRange.Cells(1, currentColumn).Value
  
          'CHECK WHETHER TO KEEP THE COLUMN
          Select Case columnHeading
  
              Case "Status", "Name", "Age"
                  'Do nothing
              Case Else
  
                  If InStr(1, _
                      Worksheets("Incidents").UsedRange.Cells(1, currentColumn).Value, _
                     "DLP", vbBinaryCompare) = 0 Then
  
                       Worksheets("Incidents").Columns(currentColumn).Delete
  
                  End If
          End Select
      Next
  
  End Sub
  </code></pre>