Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Read a single column text file


Looking for a fast easy way to efficiently read a text file into a Exce
worksheet. The text file is a single column of real numbers. Size o
the text file can be 20,000+ lines long. I want to read in the tex
file and place into column B starting at row 7. The text file an
Excel workbook are in the same directory. The size (length) of tex
file will vary from run to run, but usually around 20,000 lines i
length.

Mik

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Read a single column text file

Dim rng as Range, rng1 as Range
set rng = Activesheet.Cells(7,2)
workbooks.Open Filename:=thisWorkbook.Path & "\text1.txt"
With Activesheet
set rng1 = .Range(.Cells(1,1),.Cells(rows.count,1).End(xlup))
End With
rng1.copy Destination:=rng
activeworkbook.close savechanges:=False

--
Regards,
Tom Ogilvy

"mluetkem" wrote in message
...

Looking for a fast easy way to efficiently read a text file into a Excel
worksheet. The text file is a single column of real numbers. Size of
the text file can be 20,000+ lines long. I want to read in the text
file and place into column B starting at row 7. The text file and
Excel workbook are in the same directory. The size (length) of text
file will vary from run to run, but usually around 20,000 lines in
length.

Mike


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Read a single column text file

Would any ideas here help? The file "C:\junk.txt" would be your text file.

Sub Demo()
'// Dana DeLouis
With ActiveSheet.QueryTables.Add( _
Connection:="TEXT;C:\junk.txt", _
Destination:=Range("B7"))

.RefreshStyle = xlOverwriteCells
.AdjustColumnWidth = True
.TextFileParseType = xlDelimited
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"mluetkem" wrote in message
...

Looking for a fast easy way to efficiently read a text file into a Excel
worksheet. The text file is a single column of real numbers. Size of
the text file can be 20,000+ lines long. I want to read in the text
file and place into column B starting at row 7. The text file and
Excel workbook are in the same directory. The size (length) of text
file will vary from run to run, but usually around 20,000 lines in
length.

Mike



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Read a single column text file

Just some added info: this doesn't work in Excel 97 or earlier. The
ability to import directly into a worksheet was added in Excel 2000.

--
Regards,
Tom Ogilvy

Dana DeLouis wrote in message
...
Would any ideas here help? The file "C:\junk.txt" would be your text

file.

Sub Demo()
'// Dana DeLouis
With ActiveSheet.QueryTables.Add( _
Connection:="TEXT;C:\junk.txt", _
Destination:=Range("B7"))

.RefreshStyle = xlOverwriteCells
.AdjustColumnWidth = True
.TextFileParseType = xlDelimited
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"mluetkem" wrote in message
...

Looking for a fast easy way to efficiently read a text file into a Excel
worksheet. The text file is a single column of real numbers. Size of
the text file can be 20,000+ lines long. I want to read in the text
file and place into column B starting at row 7. The text file and
Excel workbook are in the same directory. The size (length) of text
file will vary from run to run, but usually around 20,000 lines in
length.

Mike





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
to read text tablimited file pol Excel Discussion (Misc queries) 2 May 27th 09 01:14 PM
How do you save an excel file to be read as IBM-type text file ? Dee Franklin Excel Worksheet Functions 2 October 10th 06 02:46 AM
Can delimited text file imports be extracted to a single column i. JROD Excel Discussion (Misc queries) 1 April 1st 05 05:57 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
Read text file jacob[_3_] Excel Programming 2 September 23rd 03 06:41 PM


All times are GMT +1. The time now is 04:30 AM.

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"