Maartenovich
New Member
- Joined
- Oct 16, 2014
- Messages
- 18
Hi everyone,
What I want to do is import content from a text file into a worksheet and break it down into different rows and columns. I tried a bunch of things, but can't figure it out.
What I have is this:
---
Sub Importeer()
MT940File = Application.GetOpenFilename
Open MT940File For Input As #1
Do Until EOF(1)
Line Input #1, textline
Text = Text & " " & textline
Loop
Arrayz = Split(Text, ":20:")
Close #1
For i = 0 To UBound(Arrayz)
Cells(i + 1, 1).Value = Arrayz(i)
Next i
TransNum = Application.WorksheetFunction.CountA(Range("A2:A9999"))
Dim Array1 As Variant
For i = 0 To TransNum
Array1& i = Split(Cells(i + 1, 1), " ")
Cells(1,i+2).Value = Array1&i(i)
Next i
End Sub
----
The loop breaks down de string into different rows starting at ":20:". What it should do next is break down all de rows into different columns at either spaces or, if possible, better even at previously defined values. Obviously the second loop doesn't work, but might give an impresiion of what I'm trying to do.
Much appreciated!
What I want to do is import content from a text file into a worksheet and break it down into different rows and columns. I tried a bunch of things, but can't figure it out.
What I have is this:
---
Sub Importeer()
MT940File = Application.GetOpenFilename
Open MT940File For Input As #1
Do Until EOF(1)
Line Input #1, textline
Text = Text & " " & textline
Loop
Arrayz = Split(Text, ":20:")
Close #1
For i = 0 To UBound(Arrayz)
Cells(i + 1, 1).Value = Arrayz(i)
Next i
TransNum = Application.WorksheetFunction.CountA(Range("A2:A9999"))
Dim Array1 As Variant
For i = 0 To TransNum
Array1& i = Split(Cells(i + 1, 1), " ")
Cells(1,i+2).Value = Array1&i(i)
Next i
End Sub
----
The loop breaks down de string into different rows starting at ":20:". What it should do next is break down all de rows into different columns at either spaces or, if possible, better even at previously defined values. Obviously the second loop doesn't work, but might give an impresiion of what I'm trying to do.
Much appreciated!