Hi
May you please help me with this, I spent hours trying to figure it out but couldn't. Note: I am still learning VBA.
I have 7 headings in one spreadsheet that I would want to transfer 7 text files into them.
The text files have six columns, which are separated by commas, and I would want to extract two columns out of it and paste it under the wanted heading. So that each heading have two columns of data out of one text file.
I want to open the text files in order with the oldest date text file and paste them under the headings, so that the oldest saved text file is opened under heading number-1 and following that to the recent text file under heading-7.
All I have reached to is separating a singular text file and pasting it under one heading while selected a cell. This is what I have done:
*********
Sub OpenText()
Dim FilePath As String
FilePath = "Y:\Engineering\1.txt"
Open FilePath For Input As #1
row_number = 0
Do Until EOF(1)
Line Input #1 , LineFromFile
LineItems = Split(LineFromFile, ",")
ActiveCell.Offset(row_number, 0).Value = LineItems(1)
ActiveCell.Offset(row_number, 1).Value = LineItems(4)
row_number = row_number + 1
Loop
Close #1
End Sub
*********
What I need is open text files with oldest date at once and paste them under the headings in the spreadsheet with the two wanted columns in each text file.
Thanks in advance I appreciate it much!
May you please help me with this, I spent hours trying to figure it out but couldn't. Note: I am still learning VBA.
I have 7 headings in one spreadsheet that I would want to transfer 7 text files into them.
The text files have six columns, which are separated by commas, and I would want to extract two columns out of it and paste it under the wanted heading. So that each heading have two columns of data out of one text file.
I want to open the text files in order with the oldest date text file and paste them under the headings, so that the oldest saved text file is opened under heading number-1 and following that to the recent text file under heading-7.
All I have reached to is separating a singular text file and pasting it under one heading while selected a cell. This is what I have done:
*********
Sub OpenText()
Dim FilePath As String
FilePath = "Y:\Engineering\1.txt"
Open FilePath For Input As #1
row_number = 0
Do Until EOF(1)
Line Input #1 , LineFromFile
LineItems = Split(LineFromFile, ",")
ActiveCell.Offset(row_number, 0).Value = LineItems(1)
ActiveCell.Offset(row_number, 1).Value = LineItems(4)
row_number = row_number + 1
Loop
Close #1
End Sub
*********
What I need is open text files with oldest date at once and paste them under the headings in the spreadsheet with the two wanted columns in each text file.
Thanks in advance I appreciate it much!