Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automated multiple text files into multiple sheets in one workbook Dr Dan Excel Discussion (Misc queries) 14 November 4th 07 11:32 AM
Modify macro code to export multiple cell contents to multiple Text Files [email protected] Excel Programming 3 October 14th 06 08:26 AM
Search text in multiple files in multiple directories Andrew Excel Programming 4 August 1st 06 03:43 AM
Importing multiple Text files into Excel [email protected] Excel Programming 2 April 9th 06 01:35 PM
Can I split up an excel spreadsheet into multiple files by rows? seespot Excel Discussion (Misc queries) 8 December 21st 05 10:14 PM


All times are GMT +1. The time now is 08:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"