AW: Tabstopps entfernen
08.09.2008 12:41:36
Erich
Hallo Bernd,
probier mal:
Option Explicit
Sub TextSpeichernLeerz()
Dim strT As String, strN As String, nr As Integer, zz As Long, cc As Long
strN = Application.GetSaveAsFilename(InitialFileName:="C:\temp\xxxx.txt", _
FileFilter:="Textdateien (*.txt), *.txt", _
Title:="Textfile ausgeben (Leerz.getrennt)")
If VarType(strN) = vbBoolean Then Exit Sub
nr = FreeFile(1)
Open strN For Output As #nr
For zz = 1 To LZWeTab()
strT = Cells(zz, 1)
For cc = 2 To 10 ' Spalten bis 10
strT = strT & " " & Cells(zz, cc)
Next
Print #nr, strT
Next zz
Close nr
End Sub
Function LZWeTab() As Long
Dim rng As Range
Set rng = Cells.Find("*", Cells(1, 1), xlValues, , xlByRows, xlPrevious)
If rng Is Nothing Then LZWeTab = 1 Else LZWeTab = rng.Row
End Function
Ubklar ist noch, ob auch leere Zellen mit Leerzeichen getrennt werden sollen.
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort