Yes you can.
(Note: Excel 2007 allows over 1,000,000 rows)
You can use something like:
Option Explicit
Public Const ForReading = 1, ForWriting = 2, ForAppending = 3
Sub Readfile()
Dim fso, f, DataFileName, SheetName, Str, Srow
Dim cnt, ShtNo, CurrentSheet, RowsPerSheet
CurrentSheet = "X"
DataFileName = "C:\temp\Data.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Application.ScreenUpdating = False
If (fso.fileexists(DataFileName)) Then
Set f = fso.OpenTextFile(DataFileName, ForReading)
If (Err.Number <> 0) Then
MsgBox "Could not open " & DataFileName
Exit Sub
End If
cnt = 0
RowsPerSheet = 1000
Do While Not f.AtEndOfStream
cnt = cnt + 1
ShtNo = Int(cnt / RowsPerSheet)
SheetName = "Sheet_" & ShtNo
If (SheetName <> CurrentSheet) Then
CurrentSheet = SheetName
Sheets(SheetName).Select
If (Err.Number <> 0) Then
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = SheetName
Srow = 1
End If
End If
Str = f.ReadLine
Srow = Srow + 1
Sheets(SheetName).Cells(Srow, 1) = Str
Loop
f.Close
End If
Application.ScreenUpdating = True
End Sub
Paul
________________________________
From: Saurabh <[email protected]>
To: [email protected]
Sent: Friday, September 18, 2009 8:55:48 AM
Subject: $$Excel-Macros$$ Splitting a text file
Hi All,
I am importing a text file into excel where there is more data than 65536 rows.
Can I have any macro, xla file or any addin to spilt the text file into
different sheets.
Regards,
Saurabh Patel
+919824444814
“The earth is enjoyed by heroes”—this is the unfailing truth. Be a hero. Always
say, “I have no fear.” - Swami Vivekanand
DISCLAIMER:The information contained in this electronic message and in any
attachments to this message is
confidential, legally privileged and intended only for the person or
entity to which this electronic
message is addressed. If you are not the intended recipient, please
notify the system manager and
you are hereby notified that any distribution, copying, review,
retransmission, dissemination or
other use of this electronic transmission or the information
contained in it is strictly prohibited.
Please accordingly also note that any views or opinions presented in
this email are solely those of
the author and may not represent those of the Company or bind the
Company. This message has been
scanned for viruses and dangerous content by Mail Scanner, and is
believed to be clean.
The Company accepts no liability for any damage caused by any virus
transmitted by this email.
--~--~---------~--~----~------------~-------~--~----~
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
To post to this group, send email to [email protected]
If you find any spam message in the group, please send an email to:
Ayush Jain @ [email protected] or
Ashish Jain @ [email protected]
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!
We reach over 6,500 subscribers worldwide and receive many nice notes about the
learning and support from the group. Our goal is to have 10,000 subscribers by
the end of 2009. Let friends and co-workers know they can subscribe to group at
http://groups.google.com/group/excel-macros/subscribe
-~----------~----~----~----~------~----~------~--~---