Eine Zeile zu viel
31.07.2006 11:53:37
Daniel
Ich kopiere aus Excel per makro Daten in eine txt Datei um diese in einem anderen Programm weiterzuverarbeiten.
Nun habe ich das Problem, dass das Makro in der txt-Datei immer eine Zeile zu viel schreibt. Nach dem Datensatz kommen zwei Leere Zeilen.
Es darf aber nur eine sein, sonst kommt das andere Programm nicht damit klar.
Wie muss ich das Makro ändern, damit es nur noch 1 freie Zeile am Ende gibt?
Sub TextExport()
Dim i As Long, tmp As String
Open Range("A3") & ".txt" For Output As #1
For i = 6 To 6 + Range("B4").Value - 1
tmp = ""
tmp = tmp & WorksheetFunction.Text(Cells(i, 1), "D/M/YYYY") & Chr(9)
tmp = tmp & WorksheetFunction.Substitute(Format(Cells(i, 2), "0.00000"), ",", ".") & Chr(9)
tmp = tmp & WorksheetFunction.Substitute(Format(Cells(i, 3), "0.00000"), ",", ".") & Chr(9)
tmp = tmp & WorksheetFunction.Substitute(Format(Cells(i, 4), "0.00000"), ",", ".") & Chr(9)
tmp = tmp & WorksheetFunction.Substitute(Format(Cells(i, 5), "0.00000"), ",", ".")
Print #1, tmp
Next i
Print #1, Chr(13)
Close 1
End Sub