Import from text file and break down content

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!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Got it. This did the trick:

For i = 0 To TransNum
Array1 = Split(Cells(i + 1, 1), " ")
ActiveSheet.Range(Cells(i + 1, 1), Cells(i + 1, 100)).Value = Array1

Next i
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,417
Members
448,895
Latest member
omarahmed1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top