title: Excel 2010 VBA creates weird named data range upon import of delimited text data
body: <p>I am importing a pipe delimited text file into an excel spreadsheet using a query method that I found online. The code works beautifully and fast, however, it creates a weird named range every time I run it. The issue is I cannot seem to find a valid method of deleting the range using VBA, I can only delete using the name manager. Here is my code:</p>
  
  <pre><code>Function doFileQuery(fileName As String, outSheet As String) As Boolean
  
      Dim rootDir As String
  
      rootDir = "W:\Development"
  
      Dim connectionName As String
  
      connectionName = "TEXT;" + rootDir + "\" + fileName
  
      With Worksheets(outSheet).QueryTables.Add(Connection:=connectionName, Destination:=Worksheets(outSheet).Range("A5"))
  
          .Name = fileName
          .FieldNames = True
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .PreserveFormatting = True
          .RefreshOnFileOpen = False
          .RefreshStyle = xlOverwriteCells
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .RefreshPeriod = 0
          .TextFilePromptOnRefresh = False
          .TextFilePlatform = 437
          .TextFileStartRow = 1
          .TextFileParseType = xlDelimited
          .TextFileTextQualifier = xlTextQualifierDoubleQuote
          .TextFileConsecutiveDelimiter = False
          .TextFileTabDelimiter = False
          .TextFileSemicolonDelimiter = False
          .TextFileCommaDelimiter = False
          .TextFileSpaceDelimiter = False
          .TextFileOtherDelimiter = "|"
          .Refresh BackgroundQuery:=False
  
      End With
      doFileQuery = True
  End Function
  </code></pre>
  
  <p>Here is the weird named range created:
  _11r_3_Eastdata_FrankLaRoccaMonths_c_4</p>
  
  <p>Here is how I am trying to delete it:
  ThisWorkbook.Names("_11r_3_Eastdata_FrankLaRoccaMonths_c_4").Delete</p>
  
  <p>When VB hits the above statement it gives me a </p>
  
  <p>Run Time Error '1004':</p>
  
  <p>Application defined or Object defined error.</p>
  
  <p>Any help would be greatly appreciated!</p>