title: Convert Excel 2007 sheet to tab-delimited text file
body: <p>I found this code for converting an Excel sheet to a text file. How can I modify it to create a tab-delimited text file? I am not a VB programmer, so it would help if you insert the code where it belongs.</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>Sub ExportRange()
      Dim ExpRng As Range
      Open ThisWorkbook.Path &amp; "\AllDXL.txt" For Output As #1
  
      Set ExpRng = Worksheets("Sheet1").Range("A1").CurrentRegion
      FirstCol = ExpRng.Columns(1).Column
      LastCol = FirstCol + ExpRng.Columns.Count - 1
      FirstRow = ExpRng.Rows(1).Row
      LastRow = FirstRow + ExpRng.Rows.Count - 1
      For r = FirstRow To LastRow
          For c = FirstCol To LastCol
               '  data = ExpRng.Cells(r, c).Value
              Data = Data &amp; " " &amp; ExpRng.Cells(r, c).Value
              If c = LastCol Then
                  Print #1, Data
                  Data = ""
              End If
          Next c
      Next r
      Close #1
  End Sub
  </code></pre>