Ich möchte aus einer Excel-Datei Inhalte nach txt kopieren.
Dazu habe ich im Forum ein Makro gefunden. Das habe ich versucht
anzupassen.
Bei drei Sache komme ich leider nicht zurecht:
- Wie ändere ich den Dateinamen noch so ab, dass vor dem Datum der Inhalt in F2 steht, als abcd_20_11_2006.
- Wenn die Datei einmal besteht wird sich nicht überschrieben. Wie kann man das machen?
- Im Moment wird nur Spalte A eingefügt. Ich brauche das aber von A-K.
Wäre genial, wenn mir da jemand helfen würde!
Danke.
Option Explicit
Sub exportText()
Dim strText As String
Dim lastRow As Long, lRow As Long
Dim sFile As String
Dim PfadName As String
PfadName = "C:\Temp\"
sFile = PfadName & Format(Date, "DD_MM_YYYY") & ".txt" 'Name und Pfad der Textdatei
lastRow = IIf(Range("A65536") <> "", 65536, Range("A65536").End(xlUp).Row)
Open sFile For Output As #1
For lRow = 17 To lastRow
If Len(Trim$(Cells(lRow, 1))) > 0 Then
strText = Replace(Trim$(Cells(lRow, 1)), " ", ",")
Print #1, strText
End If
Next
Close #1
End Sub