Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1584to1588
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Bereich in txt File ?

Bereich in txt File ?
17.10.2017 12:29:35
TiloT
Moin zusammen,
ich habe mal eine Frage!:
mit folgenden Code schreibe ich die ganze Tabelle in einen Textfile. Super.
Ich möchte jetzt aber nur den Bereich A13:R1000
Was muss ich tun?
Mit Range haut das nicht hin (wäre auch zu einfach, denke ich mal)
so gehts:
Dim strName As String
strName = "H:\Hier\Backups\" & _
Worksheets("Daten").Range("H1") & ".txt"
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Worksheets("Daten").Copy
Application.DisplayAlerts = False
ActiveSheet.SaveAs FileName:=strName, FileFormat:=xlTextWindows, Local:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
so nicht:
Dim strName As String
strName = "H:\Hier\Backups\" & _
Worksheets("Daten").Range("H1") & ".txt"
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Worksheets("Daten").Range("A13:R1000").Copy
Application.DisplayAlerts = False
ActiveSheet.SaveAs FileName:=strName, FileFormat:=xlTextWindows, Local:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Danke mal für Eure Hilfe
MfG
Tilo

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Bereich in txt File ?
17.10.2017 12:40:20
Rudi
Hallo,
dann lösch vor dem Speichern doch alles was du nicht willst.
Worksheets("Daten").Copy
with activesheet
Application.DisplayAlerts = False
.rows("1001:1048576").delete
.rows("1:12").delete
.columns("S:XFD").delete
.SaveAs FileName:=strName, FileFormat:=xlTextWindows, Local:=False
end with

Gruß
Rudi
AW: Bereich in txt File ?
17.10.2017 13:29:00
Peter(silie)
Hallo,
hier eine andere Möglichkeit das ganze um zu setzen.

Public Sub Data_To_Text()
Dim varItem As Variant
Dim strName, tmp As String
Dim ws As Worksheet
Dim rng As Range
Set ws = ThisWorkbook.Sheets("Daten")
With ws
strName = "H:\Hier\Backups\" & .Range("H1").Text & ".txt"
Set rng = .Range(.Cells(13, 1), .Cells(1000, 18))
For Each varItem In rng.Rows
tmp = tmp & Join(Application.Transpose(Application.Transpose(varItem.Value)), " ") & _
Chr(13)
Next varItem
Create_Textfile strName, tmp
End With
End Sub
'//Creates a New Textfile
'//Path and Input are Optional
Private Function Create_Textfile(Optional ByVal SavePath As Variant, _
Optional ByVal Input_ As Variant) As Boolean
If IsMissing(SavePath) Then SavePath = IOAgent_Defaultpath & ".txt"
Dim file_ As Long
file_ = FreeFile
Open SavePath For Output As #file_
If Not IsMissing(Input_) Then
Print #file_, Input_
End If
Close #file_
End Function
'//Creates the Default Path of the IOAgent Module
'//This is the Application Defaultpath + IOAgent_File_ + Date + Time
'//Does not add a Fileextension at the end!
Private Function IOAgent_Defaultpath() As String
IOAgent_Defaultpath = _
Application.DefaultFilePath & "\IOAgent_File_" & _
Format(Date, "dd-mm-yyyy") & "_" & Format(Time, "hh-mm-ss")
End Function

Anzeige
Besten Dank ihr 2. Nun läuft es richtig :-) owT
17.10.2017 15:02:46
TiloT
.

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige