kinimod2010
Cadet 4th Year
- Registriert
- Sep. 2014
- Beiträge
- 68
Hall Leute ich bin grad dabei aus einer Textfile mit Excel über das entwicklertool dh. VB einen text einzulesen. Ich habe noch nie mit VB gearbeitet ich habe es geschafft das er ab dem Wort "Hallo" die nächsten 20 zeilen nimmt und den rest wegwirft. jetzt will ich nur noch die sachen in die Excel Zellen aufteilen und ich schaff das nicht. Bitte um eure hilfe die Txt ist mit angehängt.
Im endefekt brauche ich nur die Zahlen so wie im TXT file im Excel um weitere berechnungen zu machen
Vielen Danks schon mal
Lg kinimod2010
Code:
Sub test()
Dim fso, fsoFile, fsoText
Dim x As Long
Dim i As Long, j As Long, k As Long
Const fsoForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.OpenTextFile("Bla_bla.txt", fsoForReading)
fsoText = Split(fsoFile.readall, vbCrLf)
fsoFile.Close
For i = 0 To UBound(fsoText) - 1 ' ohne letzte Zeile
If InStr(fsoText(i), "Hallo") Then x = i: Exit For
Next i
' k = 1
' For j = x To x + 20
' Cells(k, 1).Value = fsoText(j)
' k = k + 1
'Next j
Cells.ClearContents
For j = x To x + 20
b = b + 1
asd = Split(fsoText(j), vbTab)
i = UBound(asd)
If i = 0 Then GoTo start
For a = 1 To i
Set Cells(b, a) = Cells(b, a)
Next a
start:
Next j
End Sub
Im endefekt brauche ich nur die Zahlen so wie im TXT file im Excel um weitere berechnungen zu machen
Vielen Danks schon mal
Lg kinimod2010