nochmal txt.Import
02.10.2003 17:06:04
Heiko F.
hatte vor 2 Stunden schon die Frage gestellt und eine super Lösung bekommen
(Reinhardt und Hans ).-- DANKE!
Nun eine andere Frage. Mit dem Modul wird die txt datei ausgelesen und eingefügt.
Ich möchte nun das Modul in einer Art Mustermappe abspeichern und die txt .Datei
soll in eine vorhenden xls Datei KBR01.xls kopiert werden.
Könnt ihr mir nochmal helfen ?
Sub TextImport()
Dim arr As Variant
Dim iRow As Integer, iCounter As Integer
Dim sFile As String, sTxt As String
sFile = Range("P1").Value
If Dir(sFile) = "" Then
Beep
MsgBox "Datei wurde nicht gefunden!"
Exit Sub
End If
iRow = 9
Close
Open sFile For Input As #1
icol = 6 'F-Spalte
iRow = 9
For n = 1 To 6 'ersten 6 Zeilen überlesen
Line Input #1, sTxt
Next n
Do Until EOF(1) Or iRow > 2888
Line Input #1, sTxt
sText = sText & ";" 'damit hinter C ein ; steht falls c letzter wert in Zeile
sTxt = Right(sTxt, Len(sTxt) - InStr(sTxt, ";")) ' A weg
sTxt = Right(sTxt, Len(sTxt) - InStr(sTxt, ";")) ' B weg
Cells(iRow, icol).Value = Left(sTxt, InStr(sTxt, ";") - 1) 'C in F schreiben
iRow = iRow + 1
Loop
Close
End Sub
Danke
Heiko