View Single Post
  #4   Report Post  
Harald Staff
 
Posts: n/a
Default

Here is a macro that opens the text file and writes new parts with 20000
rows each in it. Those are written to the C:\Temp folder, shange to fit your
needs. You can of course also change 20000 to another number if you want
more / fewer rows in each file.

Sub SplitTextFile()
Dim F As Variant
Dim ToRead As String
Dim ToWrite As String
Dim ReadLine As String
Dim L As Long, M As Long
Dim iOne As Integer
Dim iTwo As Integer

F = Application.GetOpenFilename
If F = False Then Exit Sub

ToRead = CStr(F)
iOne = FreeFile
Open ToRead For Input As #iOne

L = 1

ToWrite = "C:\Temp\Part" & Format$(L, "00000000") & ".txt"
iTwo = FreeFile
Application.StatusBar = "Writing " & ToWrite
Open ToWrite For Output As #iTwo

While Not EOF(iOne)
Line Input #iOne, ReadLine
M = M + 1
If M 20000 Then
Close #iTwo
DoEvents
L = L + 1
ToWrite = "C:\Temp\Part" & _
Format$(L, "00000000") & ".txt"
Application.StatusBar = "Writing " & ToWrite
Open ToWrite For Output As #iTwo
M = 0
End If
Print #iTwo, ReadLine
Wend

Close #iOne
Close #iTwo
Application.StatusBar = False
MsgBox L & " parts written"
End Sub

HTH. Best wishes Harald


"Khawajaanwar" skrev i melding
...
Thanks for your quick reply, It dosen't matter whether it is open in a
single
file or more, i have to edit these data and the remaing file will much
much
shorter.

Thanks once again

Khawaja Anwar

"Harald Staff" wrote:

That is huge. Do you need all the data in one single place and/or at the
same time? What are you going to do with the data ? What does it contain
?

Best wishes Harald


"Khawajaanwar" skrev i melding
...
I have 390 MB data text file, i try to open this file with MS Excel only
a
part of the file was open. Please help me open this file with MS Excel
or
MS
Access
Thanks

Khawaja anwar