title: Renaming a new worksheet yields "Out of Memory" error - Why?
body: <p>I'm trying to make a new sheet and give it a name using the following code:</p>
  
  <pre><code>Sub CREATEWORKSHEETS()
  
      For Each PC In ActiveWorkbook.PivotCaches
          On Error Resume Next
          PC.Refresh
      Next PC
      PvtCache = ActiveWorkbook.PivotCaches.Create(xlDatabase, "Pivot Data!$AF:$AO")
  
      Sheets("P&amp;L Pivot").Select
      Application.DisplayAlerts = False
      On Error Resume Next
      Sheets("MAIN").Delete
      Application.DisplayAlerts = True
      On Error GoTo 0
      Sheets.Add.Name = "MAIN"
  End Sub
  </code></pre>
  
  <p>But I'm always getting an "Out of Memory" error whenever it tries to create the new "MAIN" sheet. Splitting this into the following:</p>
  
  <pre><code>Sheets.Add
  ActiveSheet.Name = "MAIN"
  </code></pre>
  
  <p>Suggests that the renaming operation is the culprit, but I can't figure out why. Does anybody have any idea why this might be happening?</p>