Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JH JH is offline
external usenet poster
 
Posts: 64
Default OpenText Method

Hi, I have a text file with many pages. It will exceed the maximum number of
rows in one Excel worksheet. Is it possible to use the OpenText method to
import this file to more than one worksheet? If not, what is the best way to
import this file?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default OpenText Method

Check out:

http://support.microsoft.com/default...b;en-us;120596

I know I have a book co-authored by Mr. Excel (www.mrexcel.com) that also
addresses this problem, but I don't have it handy.

If you have that much data, it might be easier to import it into Access and
then pull the data (65536 row at a time) into separate worksheets. (That may
be how Mr. Excel talks about doing it.)


"JH" wrote:

Hi, I have a text file with many pages. It will exceed the maximum number of
rows in one Excel worksheet. Is it possible to use the OpenText method to
import this file to more than one worksheet? If not, what is the best way to
import this file?
Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default OpenText Method

JH,

You can also modify the code given in Eric's link to use only one sheet. If
your text file is less than 16,777,216 lines you can use the following code
that will import lines up to 65536 into the first column and then lines
65537-131072 into the second column and so on until the end of file. This is
usefull if you don't want a bunch of sheets created. I've never reached the
limit before and I've processed files up to 1GB that use roughly 32 columns.
Code follows:

Sub Importfile()
Dim FileName As String
Dim ResultStr As String
Dim FileNum As Integer
Dim Counter As Double
FileName = Application.GetOpenFilename
Application.ScreenUpdating = False
If FileName = "False" Then End
FileNum = FreeFile()
Open FileName For Input As #FileNum
Sheet1.Cells(65000, 1).Select
Counter = 1
ColCounter = 1
Do While Seek(FileNum) <= LOF(FileNum)
If EOF(FileNum) Then End
Application.StatusBar = "Reading Row " & Counter & " of text file " &
FileName
Line Input #FileNum, ResultStr
ActiveCell.Value = ResultStr
If ActiveCell.Row = 65536 Then
ColCounter = ColCounter + 1
Sheet1.Cells(1, ColCounter).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Counter = Counter + 1
Loop
Close
Application.ScreenUpdating = True
Application.StatusBar = False
End Sub


Hope this helps,
Mike

"JH" wrote:

Hi, I have a text file with many pages. It will exceed the maximum number of
rows in one Excel worksheet. Is it possible to use the OpenText method to
import this file to more than one worksheet? If not, what is the best way to
import this file?
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
opentext method of excel workbook object Kislay Excel Programming 2 May 12th 05 03:56 AM
OpenText Method failure Bryan Dickerson Excel Programming 9 April 13th 05 09:29 PM
OpenText Method of Workbook Object Question John Excel Programming 2 October 20th 04 07:39 PM
How to use Opentext method with xlFixedWidth? Together[_8_] Excel Programming 2 March 3rd 04 03:27 PM
Pass string as Parameter in OpenText method No Name Excel Programming 0 January 8th 04 06:22 AM


All times are GMT +1. The time now is 06:46 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"