Importing Text File

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear All,
I waNt to connect to a text file in the memmory
so i can read line by line in the memmory to test a certain conditions and
to trim from it
and i do these opeartions i want to get these procced data to an exile file

optional :
if i can use the open dialog tool to open a file with certain condition

Tanks For Your Cooperation
 
I don't know how your data are arranged in your text file so the macro below
assumes strings of text. You will have to alter this to suit your needs.

Sub getdata()
Filename = Application.GetOpenFilename
If Filename = "False" Then Exit Sub
x = 1
Open Filename For Input As #1
Do While Not EOF(1)
Input #1, Line$
bitiwant$ = Mid$(Line$, 4, 4)
anotherbitiwant$ = Mid$(Line$, 31, 22)
Worksheets("Sheet1").Cells(x, 1).Value = bitiwant$
Worksheets("sheet1").Cells(x, 2).Value = anotherbitiwant$
x = x + 1
Loop
Close #1
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top