Posted to microsoft.public.excel.programming
|
|
Split a 2gb csv file into two files
Bernie,
Thanks, that was a big help
Cheers
Bernie Deitrick wrote:
Ozzie,
You could try a macro like the one below - a little tweaking of the upper limits on the loops may
be needed....
HTH,
Bernie
MS Excel MVP
Sub SplitFiles()
Dim ReadStr As String
Dim FileName1 As String
Dim OrigFNum As Integer
Dim FileNumOut As Integer
Dim Counter As Double
Dim i As Integer
Dim j As Long
Counter = 1
FileName1 = Application.GetOpenFilename( _
"CSV Files (*.csv),*.csv", _
, "Pick the Original File")
If FileName1 = "" Then End
OrigFNum = FreeFile()
Open FileName1 For Input As #OrigFNum
For i = 1 To 10
FileNumOut = FreeFile()
Open "SplitFile" & i & ".csv" For Output Access Write As #FileNumOut
For j = 1 To 50000
Application.StatusBar = "Processing line " & Counter
Line Input #OrigFNum, ReadStr
Print #FileNumOut, ReadStr
Counter = Counter + 1
Next j
Close #FileNumOut
Next i
Close #OrigFNum
Application.StatusBar = False
End Sub
Guys,
[quoted text clipped - 9 lines]
Cheers
--
Message posted via http://www.officekb.com
|