Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple text files to multiple rows in excel
Hi,
I have an excel sheet containing two columns "Text File Name" & "Text File Content", there are more than 2000 rows. On my hard disk there is a folder in which all the text files are stored. I have to import Line number 4 from text files in the cell next to "Text File Name". The format of the excel sheet is as below: TEXT FILE NAME TEXT FILE CONTENT File_1 (This content is needed from text "File_1") File_2 (This content is needed from text "File_2") File_3 (This content is needed from text "File_3") ........... I hope to find a proper solution here. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
multiple text files to multiple rows in excel
Sub GetLine4()
Const folder = "c:\Temp\Test" Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim fs, f Set fs = CreateObject("Scripting.FileSystemObject") RowCount = 1 Do While Range("A" & RowCount) < "" Filename = Range("A" & RowCount) Set f = fs.OpenTextFile(Filename, _ ForReading) For LineCount = 1 To 3 f.readline Next LineCount InputLine = f.readline Range("B" & RowCount) = InputLine f.Close RowCount = RowCount + 1 Loop End Sub "Vindhyawasini" wrote: Hi, I have an excel sheet containing two columns "Text File Name" & "Text File Content", there are more than 2000 rows. On my hard disk there is a folder in which all the text files are stored. I have to import Line number 4 from text files in the cell next to "Text File Name". The format of the excel sheet is as below: TEXT FILE NAME TEXT FILE CONTENT File_1 (This content is needed from text "File_1") File_2 (This content is needed from text "File_2") File_3 (This content is needed from text "File_3") .......... I hope to find a proper solution here. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Automated multiple text files into multiple sheets in one workbook | Excel Discussion (Misc queries) | |||
Modify macro code to export multiple cell contents to multiple Text Files | Excel Programming | |||
Search text in multiple files in multiple directories | Excel Programming | |||
Importing multiple Text files into Excel | Excel Programming | |||
Can I split up an excel spreadsheet into multiple files by rows? | Excel Discussion (Misc queries) |