Welcome to Lockergnome.com!
HomeHome FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

How can I open big file?

 
   Home -> Office -> Setup RSS
Next:  Setup: Excel 2003 cell formatting  
Author Message
Armandc

External


Since: Aug 06, 2007
Posts: 1



(Msg. 1) Posted: Mon Aug 06, 2007 5:00 am
Post subject: How can I open big file?
Archived from groups: microsoft>public>excel>setup (more info?)

How can I open a file which contains more than 65 536 rows?
Back to top
Login to vote
Niek Otten

External


Since: Feb 23, 2004
Posts: 1910



(Msg. 2) Posted: Mon Aug 06, 2007 3:03 pm
Post subject: Re: How can I open big file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Use this macro from Bernie Deitrick

If you're new to macros:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

===========================================================
' Importing a large file into Excel. File MAY have more than 65,000 records
' and will automatically start a new sheet.


Sub LargeFileImport()
'Bernie Deitrick's code for opening very large text files in Excel
'Dimension Variables
Dim ResultStr As String
Dim FileName As String
Dim FileNum As Integer
Dim Counter As Double
'Ask User for File's Name
FileName = Application.GetOpenFilename
'Check for no entry
If FileName = "" Then End
'Get Next Available File Handle Number
FileNum = FreeFile()
'Open Text File For Input
Open FileName For Input As #FileNum
'Turn Screen Updating Off
Application.ScreenUpdating = False
'Create A New WorkBook With One Worksheet In It
Workbooks.Add Template:=xlWorksheet
'Set The Counter to 1
Counter = 1
'Loop Until the End Of File Is Reached
Do While Seek(FileNum) <= LOF(FileNum)
'Display Importing Row Number On Status Bar
Application.StatusBar = "Importing Row " & Counter & " of text file " _
& FileName
'Store One Line Of Text From File To Variable
Line Input #FileNum, ResultStr
'Store Variable Data Into Active Cell
If Left(ResultStr, 1) = "=" Then
ActiveCell.Value = "'" & ResultStr
Else
ActiveCell.Value = ResultStr
End If
If ActiveCell.Row = 65536 Then
'If On The Last Row Then Add A New Sheet
ActiveWorkbook.Sheets.Add
Else
'If Not The Last Row Then Go One Cell Down
ActiveCell.Offset(1, 0).Select
End If
'Increment the Counter By 1
Counter = Counter + 1
'Start Again At Top Of 'Do While' Statement
Loop
'Close The Open Text File
Close
'Remove Message From Status Bar
Application.StatusBar = False
End Sub

' ===========================================================

"Armandc" <Armandc DeleteThis @discussions.microsoft.com> wrote in message news:DD73F181-300D-4162-997E-76ED919714C2@microsoft.com...
| How can I open a file which contains more than 65 536 rows?
Back to top
Login to vote
JLatham

External


Since: Sep 19, 2006
Posts: 1511



(Msg. 3) Posted: Tue Aug 07, 2007 12:10 pm
Post subject: Re: How can I open big file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

That code is 'limited' to importing text files, correct? And will import
each row of the text file as a single entry into the rows on the worksheet?

Armandc - take note of those limitations. If your desire is to import a
data from an Excel 2007 file with more than 65536 rows of data, you may need
to attack it in a different manner:
Have the person with Excel 2007 save the file as a .csv file.
Download this file from my site (click the link and choose Save) to your
hard drive. Open that file [it does have macros so your macro security may
need to be reset] and follow the instructions:
http://www.jlathamsite.com/uploads/ImportExcessRowsOfData.xls

If you ever need to import a .csv type file with more than 256 columns of
data (but less than a full page of rows) then this other file may help you:
http://www.jlathamsite.com/uploads/ImportExcessColumnsOfData.xls


"Niek Otten" wrote:

> Use this macro from Bernie Deitrick
>
> If you're new to macros:
>
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>
> ===========================================================
> ' Importing a large file into Excel. File MAY have more than 65,000 records
> ' and will automatically start a new sheet.
>
>
> Sub LargeFileImport()
> 'Bernie Deitrick's code for opening very large text files in Excel
> 'Dimension Variables
> Dim ResultStr As String
> Dim FileName As String
> Dim FileNum As Integer
> Dim Counter As Double
> 'Ask User for File's Name
> FileName = Application.GetOpenFilename
> 'Check for no entry
> If FileName = "" Then End
> 'Get Next Available File Handle Number
> FileNum = FreeFile()
> 'Open Text File For Input
> Open FileName For Input As #FileNum
> 'Turn Screen Updating Off
> Application.ScreenUpdating = False
> 'Create A New WorkBook With One Worksheet In It
> Workbooks.Add Template:=xlWorksheet
> 'Set The Counter to 1
> Counter = 1
> 'Loop Until the End Of File Is Reached
> Do While Seek(FileNum) <= LOF(FileNum)
> 'Display Importing Row Number On Status Bar
> Application.StatusBar = "Importing Row " & Counter & " of text file " _
> & FileName
> 'Store One Line Of Text From File To Variable
> Line Input #FileNum, ResultStr
> 'Store Variable Data Into Active Cell
> If Left(ResultStr, 1) = "=" Then
> ActiveCell.Value = "'" & ResultStr
> Else
> ActiveCell.Value = ResultStr
> End If
> If ActiveCell.Row = 65536 Then
> 'If On The Last Row Then Add A New Sheet
> ActiveWorkbook.Sheets.Add
> Else
> 'If Not The Last Row Then Go One Cell Down
> ActiveCell.Offset(1, 0).Select
> End If
> 'Increment the Counter By 1
> Counter = Counter + 1
> 'Start Again At Top Of 'Do While' Statement
> Loop
> 'Close The Open Text File
> Close
> 'Remove Message From Status Bar
> Application.StatusBar = False
> End Sub
>
> ' ===========================================================
>
> "Armandc" <Armandc RemoveThis @discussions.microsoft.com> wrote in message news:DD73F181-300D-4162-997E-76ED919714C2@microsoft.com...
> | How can I open a file which contains more than 65 536 rows?
>
>
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Setup All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 General
 Microsoft Windows XP
 Microsoft Windows Vista
 Microsoft Windows (other)
  Microsoft Office
 Microsoft Office (other)
 Computer Security
 Linux
 Movies


[ Contact us | Terms of Service/Privacy Policy ]