AW: Excel-Liste in Textdateien aufspalten
23.06.2008 17:47:00
fcs
Hallo Bernd,
hier mein Lösungsvorschlag.
Gruß
Franz
Sub TextExport()
Dim lngZeile As Long, lngAnzZeilen As Long, lngSatz As Long
Dim objWks As Worksheet
Dim intFF As Integer
Dim intCount As Integer, strDateiname As String, strDateinameTxt As String
lngAnzZeilen = Application.InputBox(Prompt:="Anzahl Zeilen pro Textdatei", _
Title:="Export Textdatei", Default:=300, Type:=1)
If lngAnzZeilen .Cells(.Rows.Count, 1).End(xlUp).Row
intCount = intCount + 1 'Zähler für Dateinamen
strDateinameTxt = ActiveWorkbook.Path & "\" & strDateiname & Format(intCount, "000") _
& ".txt"
intFF = FreeFile()
Open strDateinameTxt For Output As #intFF
lngSatz = 0
Do Until lngSatz = lngAnzZeilen _
Or lngZeile > .Cells(.Rows.Count, 1).End(xlUp).Row
'Werte aus Spalte 1 und 2 in Textdatei schreiben, Trennzeichen: Tab
Print #intFF, .Cells(lngZeile, 1) & vbTab & .Cells(lngZeile, 2)
lngSatz = lngSatz + 1
lngZeile = lngZeile + 1
Loop
Close #intFF
Loop
End With
MsgBox "Fertig mit Export"
End Sub