title: Excel VBA script freezes excel after running for a few minutes
body: <p>While my code works for 10 loop iterations, it crashes for home = 30 or more. Can someone please provide me with a clue? Even weirder this code used to work fine... and is not working anymore.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>Sub datascrap_clean()
  
  '
  
  Application.Calculation = xlCalculationManual
  Application.ScreenUpdating = False
  
  Dim home                As Integer
  
  Dim output_rows         As Integer
  Dim output_columns      As Integer
  Dim date_columns        As Integer
  
  
  'Output rows and columns starting values
  output_rows = 3
  output_columns = 3
  date_columns = 8
  
  For home = 3 To 33
  
      With ActiveSheet.QueryTables.Add(Connection:= _
          "URL;http://www.cqc.org.uk/directory/" &amp; Sheets("Output").Cells(home, 1), Destination:=Range("$A$1") _
          )
          '.CommandType = 0
          .Name = "Homes"
          .FieldNames = True
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .PreserveFormatting = True
          .RefreshOnFileOpen = False
          .BackgroundQuery = True
          .RefreshStyle = xlInsertDeleteCells
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .RefreshPeriod = 0
          .WebSelectionType = xlEntirePage
          .WebFormatting = xlWebFormattingNone
          .WebPreFormattedTextToColumns = True
          .WebConsecutiveDelimitersAsOne = True
          .WebSingleBlockTextImport = False
          .WebDisableDateRecognition = False
          .WebDisableRedirections = False
          .Refresh BackgroundQuery:=False
      End With
  
  
  
  
  For x = 20 To 250
      Select Case Left(Cells(x, 1), 7)
  
      'Is it a score?
      Case Is = "Overall"
  
          Sheets("Output").Cells(output_rows, output_columns).Value = Cells(x, 1)
          output_columns = output_columns + 1
  
      'Is it a date?
      'Case Is = "Carried"
  
         ' Sheets("Output").Cells(output_rows, output_columns).Value = Cells(x, 1)
          'date_columns = date_columns + 1
  
      Case Else
  
      End Select
  
      Sheets(2).Select
  
  Next x
  
      'Clean sheet
      ActiveSheet.Cells.Delete
  
      'Reset column count
      output_columns = 3
      date_columns = 8
  
  output_rows = output_rows + 1
  Next home
  
  
  
  MsgBox ("Done!")
  End Sub
  </code></pre>