How to export Excel data to Text files in Excel?

If you are required to deliver a workbook in the format of text file, you need to convert the workbook into text files. And this article will introduce you two methods to export Excel data into text files easily.

Export Excel data to text files with the Save As command

Export selected range or worksheet to text file with VBA code

Export selected range or worksheet to text file with Kutools for Excel

Kutools for Excel: add 120 new features in Excel. Save one hour every day.
Classic Menu for Office: brings back classic menus to Office 2010 and 2013 (includes Office 365).
Office Tab: brings tabbed interface to Office as the use of web browser Chrome, Firefox and Internet Explorer.

arrow blue right bubble Export Excel data to text files with the Save As command

Hot
Amazing! Using Tabs in Excel like Firefox, Chrome, Internet Explore 10!

By default, the Excel data will be saved as workbooks in the format of .xlsx. However, we can export a worksheet of existing workbook as text files with the following steps:

Step 1: Click the Save as button under File tab in Excel 2010; in Excel 2007 click the Office Button and Save as button;

Step 2: Save As dialog box comes out. Name the file in the File name text box and select the folder that you will save the file in;

Step 3: In the Save as type drop down list, select the Unicode Text . See screenshot:

doc-data-to-text-1

Step 4: Then it will pop up two warning dialog boxes asking you to export only active worksheet as text file and leave out any incompatible features with text file. Click OK and Yes.

doc-data-to-text-2
-1
doc-data-to-text-3

Then the data in the active worksheet are exported as a new text file.

Note: the Save As command is only able to export data of active worksheet as a text file. If you want to export all data of the whole workbook, you need to save each worksheet as a text file individually.


arrow blue right bubble Export selected range or worksheet to text file with VBA code

The following VBA code also can help you to export the selected range data or entire worksheet to the text file, please do as this:

Step 1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

Step 2. Click Insert > Module, and paste the following code in the Module Window.

VBA: export selection or entire worksheet to text file

Sub ExportRangetoFile()
'Update 20130913
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Step 3. Then press F5 key to run this code, and a prompt box will pop out to tell you to select the data range that you want to export, see screenshot:

doc-data-to-text-4

Note: If you want to export the entire worksheet, in the above prompt box, hold down the Ctrl + A keys.

Step 4. Then click OK, and specify a name for this text file and a folder to put this file in the popped out Save As dialog.

doc-data-to-text-5

Step 4. Then click Save button, and the selected data range has been exported as text file.


arrow blue right bubble Export selected range or worksheet to text file with Kutools for Excel

The Save As command can export all data in the active worksheet as text. What if exporting all data of specified inactive worksheets, or part of the data in a worksheet as a text file? Kutools for Excel's Export Range to File tool can help us export and save the data in any worksheet as text file easily no matter it is active or not.

Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.

After installing Kutools for Excel, please do as following steps:

Step 1: Click Enterprise > Import / Export > Export Range to File, see screenshot:

doc-data-to-text-6

Step 2: In the Export Range to File dialog box, do following options:

  • (1.) Click the doc-data-to-csv-6 button to select a range that you want to export its data as a text file. If you want to export the entire worksheet, after clicking the doc-data-to-csv-6 button, then hold down the Ctrl + A keys.
  • (2.) Then check the Unicode Text option under File format, and then choose the text options as you need, see screenshot:

doc-data-to-text-7

Step 3: Then click OK, and specify a name and a location for the exported range file.

doc-data-to-text-8

Step 4: And then click Save, now the selected range is exported as a new text file. See screenshot:

doc-data-to-text-9

Kutools for Excel's Export Range to File tool makes it possible to easily export a range of date to a file, either an Excel workbook, a CSV, a simple HTML or all formatting HTML.

arrow blue right bubble Related Articles:


Kutools for Excel

More than 120 Advanced Functions for Excel 2013, 2010, 2007 and Office 365.

screen shot

btn read more     btn download     btn purchase

Comments  

0#amsarajan2014-03-04 14:45
really is it very usefull,thanku :D
Reply | Reply with quote | Quote

Add comment


Security code
Refresh