Import/Export Text File Tab Delimiter

  • Thread starter Thread starter Cool Sport
  • Start date Start date
C

Cool Sport

Hi there,

I would like to import/export data to text files using tab delimiter.
This helps user to save/load configurations or share them with others.

I know how to import a text file to a range. How can I export a range of
cells into a text file so that it can be loaded later.

Regards,
 
method (1)
copy the range to a new workbook, then saevas using the CSV as a delimer

Option Explicit

Sub SaveToCSV()

Dim Source As Range
Dim wb As Workbook

Set Source = Range("MyData")

Set wb = Workbooks.Add()

wb.ActiveSheet.Range(Source.Address).Value = Source.Value

wb.SaveAs "c:\temp\MyCSV.csv", xlCSV

wb.Close False

End Sub

Method(2)
OPEN a stream to a text file & write the data line by line. Build the line
using a FOR...NEXT loop concotenating the cell values with a ";" .... much to
tedious!

HTH
Patrick Molloy
Microsoft Excel MVP
 
Here is an additional thought:

If you want Tab delimited, go to File=>Save As and select Tab delimited as
the file type.

If you want code, turn on the macro recorder while you do it manually.
(record to a different workbook than the one being saved as a tab delimited
file).
 
Back
Top