ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Importing Text File (https://www.excelbanter.com/excel-programming/385230-importing-text-file.html)

Import Text File

Importing Text File
 
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

Mike

Importing Text File
 
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


"Import Text File" wrote:

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



All times are GMT +1. The time now is 06:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com