Direkt zum Inhalt

Wie exportiere ich Excel-Daten (Auswahl oder Blätter) in Textdateien in Excel?

Wenn Sie eine Arbeitsmappe im Format einer Textdatei bereitstellen müssen, müssen Sie die Arbeitsmappe in Textdateien konvertieren. In diesem Artikel werden zwei Methoden zum einfachen Exportieren von Excel-Daten in Textdateien vorgestellt.

Exportieren Sie ein einzelnes Blatt in eine Textdatei in Excel

Standardmäßig werden die Excel-Daten als Arbeitsmappen im Format gespeichert . Xlsx. Wir können jedoch ein Arbeitsblatt einer vorhandenen Arbeitsmappe als Textdateien mit dem exportieren Speichern unter Merkmal. Bitte gehen Sie wie folgt vor:

1. Wechseln Sie zu dem Arbeitsblatt, das Sie in eine Textdatei exportieren möchten, und klicken Sie auf Reichen Sie das (oder Office-Schaltfläche)> Speichern unter.

2. In der Eröffnung Speichern unter Wählen Sie im Dialogfeld den Zielordner aus, in dem Sie die exportierte Textdatei speichern möchten, und benennen Sie die Datei im Dateiname Feld, und wählen Sie dann die Unicode-Text (* .txt) aus dem Speichern als Typ Dropdown-Liste. Siehe Screenshot:
Export in Textdatei mit der Funktion Speichern unter

3. Daraufhin werden zwei Warndialogfelder angezeigt, in denen Sie aufgefordert werden, nur aktives Arbeitsblatt als Textdatei zu exportieren und inkompatible Funktionen mit Textdateien wegzulassen. Klicken OK -Taste und Ja Taste nacheinander.

Anschließend werden die Daten im aktiven Arbeitsblatt als neue Textdatei exportiert.

Note: das Speichern unter Befehl kann nur Daten des aktiven Arbeitsblatts als Textdatei exportieren. Wenn Sie alle Daten der gesamten Arbeitsmappe exportieren möchten, müssen Sie jedes Arbeitsblatt einzeln als Textdatei speichern.


Exportieren Sie die Auswahl (oder eine Spalte) mit VBA in eine Textdatei

Der folgende VBA-Code kann Ihnen auch beim Exportieren der ausgewählten Bereichsdaten (z. B. einer Spalte) in die Textdatei helfen. Gehen Sie dazu folgendermaßen vor:

1. Halten Sie die ALT + F11 Tasten, und es öffnet die Microsoft Visual Basic für Applikationen Fenster.

2. Klicken Sie auf Kostenlos erhalten und dann auf Installieren. Insert > Modulund fügen Sie den folgenden Code in das Modulfenster ein.

VBA: Exportauswahl oder gesamtes Arbeitsblatt in Textdatei

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

3. Dann drücken F5 Schlüssel zum Ausführen dieses Codes. Wählen Sie dann im Popup-Dialogfeld den Datenbereich aus, den Sie exportieren möchten, und klicken Sie auf OK Schaltfläche, siehe Screenshot:
Wählen Sie eine Spalte aus, die als Textdatei exportiert werden soll

4. Geben Sie nun in einem anderen Dialogfeld Speichern unter einen Namen für diese Textdatei und einen Ordner an, in den diese Datei abgelegt werden soll, und klicken Sie auf Speichern .


Exportieren Sie die Auswahl (oder eine Spalte) mit Kutools for Excel in eine Textdatei

Das Speichern unter Befehl kann alle Daten im aktiven Arbeitsblatt als Text exportieren. Was ist, wenn alle Daten bestimmter inaktiver Arbeitsblätter oder ein Teil der Daten in einem Arbeitsblatt als Textdatei exportiert werden? Kutools für Excel's Bereich in Datei exportieren Das Dienstprogramm kann uns helfen, die ausgewählten Daten einfach als Textdatei zu exportieren und zu speichern.  

Kutools for Excel - Vollgepackt mit über 300 wichtigen Tools für Excel. Genießen Sie eine 30-tägige KOSTENLOSE Testversion mit vollem Funktionsumfang, ohne dass eine Kreditkarte erforderlich ist! Jetzt herunterladen!

1. Wählen Sie den Bereich aus, den Sie in eine Textdatei exportieren möchten (in unserem Fall wählen wir die Spalte A aus), und klicken Sie auf Kutoolen Plus > Import / Export > Bereich in Datei exportieren, siehe Screenshot:
Excel-Add-In: Auswahl in Textdatei exportieren

2. Im Bereich in Datei exportieren Gehen Sie wie folgt vor:
Excel-Add-In: Auswahl in Textdatei exportieren
(1) Überprüfen Sie die Unicode-Text Option in der Datei Format Sektion;
(2) Aktivieren Sie die Option Aktuelle Werte speichern oder Werte wie auf dem Bildschirm angezeigt speichern, wie Sie im Abschnitt Textoptionen benötigen.
(3) Geben Sie den Zielordner an, in dem Sie die exportierte Textdatei speichern möchten.
(4) Klicken Sie auf Ok .

3. Benennen Sie die exportierte Textdatei im neuen Öffnungsdialogfeld und klicken Sie auf Ok .
Benennen Sie die exportierte Textdatei

Anschließend wurde die Auswahl (ausgewählte Spalte A) als Textdatei exportiert und im angegebenen Ordner gespeichert.

Kutools for Excel - Laden Sie Excel mit über 300 wichtigen Tools auf. Genießen Sie eine 30-tägige KOSTENLOSE Testversion mit vollem Funktionsumfang, ohne dass eine Kreditkarte erforderlich ist! Hol es dir jetzt


Exportieren Sie mehrere Blätter in separate Textdateien in Excel

Manchmal müssen Sie möglicherweise mehrere Arbeitsblätter in mehrere Textdateien in Excel exportieren. Die Funktion Speichern unter ist möglicherweise etwas langweilig! Keine Sorge! Kutools für Excel Arbeitsmappe teilen Das Dienstprogramm bietet Excel-Benutzern eine einfache Problemumgehung, um mehrere Arbeitsblätter mit mehreren Klicks in viele separate Textdateien zu exportieren. 

Kutools for Excel - Vollgepackt mit über 300 wichtigen Tools für Excel. Genießen Sie eine 30-tägige KOSTENLOSE Testversion mit vollem Funktionsumfang, ohne dass eine Kreditkarte erforderlich ist! Jetzt herunterladen!

1 Klicken Kutoolen Plus > WorkbookArbeitsmappe teilen. Siehe Screenshot:
Excel-Add-In: Exportieren Sie mehrere Blätter in Textdateien

2. Gehen Sie im sich öffnenden Dialogfeld "Arbeitsmappe teilen" wie folgt vor:
Excel-Add-In: Exportieren Sie mehrere Blätter in Textdateien
(1) Überprüfen Sie die Arbeitsblätter, die Sie in separate Textdateien exportieren möchten Name der Arbeitsmappe Sektion;
(2) Überprüfen Sie die Geben Sie das Sicherungsformat an Option und wählen Sie dann die Option Unicode-Text (* .txt) von unten Dropdown-Liste, siehe Screenshot links:
(3) Klicken Sie auf Split .

3. Wählen Sie dann im daraufhin angezeigten Dialogfeld Nach Ordner suchen den Zielordner aus, in dem Sie exportierte Textdateien speichern möchten, und klicken Sie auf OK .

Bisher wurde jedes angegebene Arbeitsblatt als separate Textdatei exportiert und im angegebenen Ordner gespeichert.

Kutools for Excel - Laden Sie Excel mit über 300 wichtigen Tools auf. Genießen Sie eine 30-tägige KOSTENLOSE Testversion mit vollem Funktionsumfang, ohne dass eine Kreditkarte erforderlich ist! Hol es dir jetzt

Speichern Sie jedes Blatt einfach als separate PDF- / Text- / CSV-Datei oder Arbeitsmappe in Excel

Normalerweise können wir aktives Arbeitsblatt als separate PDF-, TXT- oder CSV-Datei mit der Funktion Speichern unter speichern. Aber Kutools für Excel Arbeitsmappe teilen Mit dem Dienstprogramm können Sie jede Arbeitsmappe einfach als separate PDF / TEXT / CSV-Datei oder Arbeitsmappe in Excel speichern.


Ad Split Workbook PDF 1

Kutools for Excel - Laden Sie Excel mit über 300 wichtigen Tools auf. Genießen Sie eine 30-tägige KOSTENLOSE Testversion mit vollem Funktionsumfang, ohne dass eine Kreditkarte erforderlich ist! Hol es dir jetzt


Demo: Exportieren Sie Excel-Daten (Auswahl oder Blätter) in Textdateien in Excel


Kutools for Excel: Über 300 praktische Werkzeuge immer zur Hand! Starten Sie noch heute Ihre 30-tägige kostenlose Testversion ohne Funktionseinschränkungen. Jetzt herunterladen!

Weitere Artikel:

Beste Office-Produktivitätstools

🤖 Kutools KI-Assistent: Revolutionieren Sie die Datenanalyse basierend auf: Intelligente Ausführung   |  Code generieren  |  Erstellen Sie benutzerdefinierte Formeln  |  Analysieren Sie Daten und erstellen Sie Diagramme  |  Rufen Sie Kutools-Funktionen auf...
Beliebte Funktionen: Suchen, markieren oder identifizieren Sie Duplikate   |  Leere Zeilen löschen   |  Kombinieren Sie Spalten oder Zellen, ohne Daten zu verlieren   |   Runde ohne Formel ...
Super-Lookup: VLookup mit mehreren Kriterien    VLookup mit mehreren Werten  |   VLookup über mehrere Blätter hinweg   |   Unscharfe Suche ....
Erweiterte Dropdown-Liste: Erstellen Sie schnell eine Dropdown-Liste   |  Abhängige Dropdown-Liste   |  Mehrfachauswahl Dropdown-Liste ....
Spaltenmanager: Fügen Sie eine bestimmte Anzahl von Spalten hinzu  |  Spalten verschieben  |  Schalten Sie den Sichtbarkeitsstatus ausgeblendeter Spalten um  |  Vergleichen Sie Bereiche und Spalten ...
Ausgewählte Funktionen: Rasterfokus   |  Designansicht   |   Große Formelleiste    Arbeitsmappen- und Blattmanager   |  Ressourcen (Autotext)   |  Datumsauswahl   |  Arbeitsblätter kombinieren   |  Zellen verschlüsseln/entschlüsseln    Senden Sie E-Mails nach Liste   |  Superfilter   |   Spezialfilter (Filter fett/kursiv/durchgestrichen...) ...
Top 15 Toolsets12 Text Tools (Text hinzufügen, Zeichen entfernen, ...)   |   50+ Chart Typen (Gantt-Diagramm, ...)   |   40+ Praktisch Formeln (Berechnen Sie das Alter basierend auf dem Geburtstag, ...)   |   19 Einfügen Tools (QR-Code einfügen, Bild aus Pfad einfügen, ...)   |   12 Umwandlung (Conversion) Tools (Zahlen zu Wörtern, Currency Conversion, ...)   |   7 Zusammenführen & Teilen Tools (Erweiterte Zeilen kombinieren, Zellen teilen, ...)   |   ... und mehr

Verbessern Sie Ihre Excel-Kenntnisse mit Kutools für Excel und erleben Sie Effizienz wie nie zuvor. Kutools für Excel bietet über 300 erweiterte Funktionen, um die Produktivität zu steigern und Zeit zu sparen.  Klicken Sie hier, um die Funktion zu erhalten, die Sie am meisten benötigen ...

Beschreibung


Office Tab Bringt die Oberfläche mit Registerkarten in Office und erleichtert Ihnen die Arbeit erheblich

  • Aktivieren Sie das Bearbeiten und Lesen von Registerkarten in Word, Excel und PowerPoint, Publisher, Access, Visio und Project.
  • Öffnen und erstellen Sie mehrere Dokumente in neuen Registerkarten desselben Fensters und nicht in neuen Fenstern.
  • Steigert Ihre Produktivität um 50 % und reduziert jeden Tag Hunderte von Mausklicks für Sie!
Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How would I amend the code for Export selection (or one column) to text file with VBA to autofill the filename with the contents of cell B2?
thanks
This comment was minimized by the moderator on the site
Hi,This is great, thanks a lot.
How would I alter the code for Export selection (or one column) to text file with VBA to auto fill the filename with the contents of cell B2?
This comment was minimized by the moderator on the site
Hi, this code is very useful for me. So thank you very much.
I want to ask that: When i'm using this code, a new line append automatically at the end of the txt content.
Can you help me about preventing this by vba?
This comment was minimized by the moderator on the site
hi guys, i used that code:
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

and have working, but i need to savea column with cells that contain the function"concatenate", and when i play the vba code, and i save the .TXT file, only what appears it's #REF. how can i to fix it? cause i need the data that appears on that cells?
This comment was minimized by the moderator on the site
Has anyone been able to figure this out? I am having the same issue.
This comment was minimized by the moderator on the site
HELLO
THANK YOU FOR YOUR VBA CODE
SOMETIMES ON CERTAIN TEXT THERE IS "TEXT" IN EXPORT .TXT
THANK YOU FOR WHY
This comment was minimized by the moderator on the site
Thanks for the awesome piece of VBA code to export data to a text file. I have used your code with some of my own. The data I am dealing with is extremely line-length specific and after the macro has run, the text file contains some double quotation marks " at random places, which was never present in my data before. I have tried adding a code line to remove this character at various stages but that does not seem to be working. I am aware that I can manually remove this but would like to resolve it in the VBA code.

Sub Macro3()
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B$10591").AutoFilter Field:=1, Criteria1:= _
"=NSZAP*", Operator:=xlAnd
Range("A1").Select
ActiveCell.Offset(200, 0).Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Rows("1:10101").EntireRow.Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Selection.AutoFilter
Range(Selection, Selection.End(xlDown)).Select
Set WorkRng = Application.Selection
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi Harish,
For removing a specified character in bulk, you can replace the character with nothing.
Ctrl + H to open the Find and Replace dialog box, type the specified character in the Find what box, and type noting in the replace with box.
This comment was minimized by the moderator on the site
3/2 You might also note that you don't need to specify the wb prefix once you've .Add ed the workbook since it becomes active. Specifying wb might or might not be more efficient but it can be omitted from some commands. Actually I entirely scrapped the variable wb; I just go Workbooks.Add, and use ActiveWorkbook when needed. (As you are suppressing ScreenUpdating it wouldn't be obvious to some that wb is Active. Tip for beginners (and higher): I always, always develop with ScreenUpdating and DisplayAlerts as True, and when done with development, I consider toggling them off for some passage of code.)
This comment was minimized by the moderator on the site
2/2 - vbYesNoCancel msgboxes and Booleans to indicate whether to export all, selection, or a user specified range - a static String for the prior range address - if len(that static)1 then I set WorkRng=activesheet.UsedRange (You can't copy multiple areas with a single copy, though with a little work you could walk the areas and copy them piecemeal.) - Idiotic Microsoft does not save off empty rows at the start and the bottom of the saved range, and does not save off empty columns at the leftmost and the rightmost of the saved range. When I detect that (UsedRange is not row 1, col. 1, or xlLastCell is not completely lower-right) I msgbox to ask user if they want to plug A1 or the lower right cell. - Then I decided to preemptively address the upper left issue by inserting a row and setting A1 to be text like "The following is for range " - I close with activeworkbook.close SaveChanges:=False - Long time habit since I'm an angry proponent of cleaning up (and the world is a sad place thanks to irresponsible programmers who shirk that responsibility when it matters), I set WorkRng = Nothing on the way out :)
This comment was minimized by the moderator on the site
1/2 (since your software limits comment length) I am a serious coder and I want to inform you that the VBA code here is outstanding. It's clean, and not one line too much, or one too few. It's exemplary coding for demonstration of the process. I'll also mention that as I extensively researched solutions for export of selection, you and only one other person suggested dropping the range into a temp new workbook. All other answers were painfully manually, walking through cell by cell. Even Chip's code is much longer and runs slower (but intentionally so, as it is much more flexible - specifiable delimiters, etc.) Just for your amusement, I made some very minor tweaks but otherwise nearly lifted the code word for word because it basically dropped right into a very intricate and specialized application. Some of these tweaks are something I'm sure you do in practice, but they add lines of code (e.g. error checking) so showing them on this webpage would have muddied your display so that the essential elements of processing would have been cumbersome for readers to follow along. Anyway: (see part 2)
This comment was minimized by the moderator on the site
My query is as mentioned below: I have a report to generate everyday. The data what I get on the final row (only one row but more than one columns) I want it to export to another excel sheet which is a summary excel sheet saved separately on my desktop. Eg: Day1 report - final row export to Summary excel sheet row1 Day2 report - final row export to Summary excel sheet row2 Day3 report - final row export to Summary excel sheet row3 and so on.. Export should be done through a click button., which means when I click on export button the data on the sheet I calculated today should go and save on the Summary excel sheet row1, next day a new excel sheet report calculated should go and save on the Summary excel sheet row2 and so on.. Will this be possible to do... If yes please someone help me on this... Thank you in advance...:-)
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations