too many rows in csv file
Ta very much - just the ticket
(please excuse the language -- I'm British)!
Cheers
"Dave O" wrote:
If the issue is that the file contains more rows than Excel can
accommodate, 65,536, then run this macro to parse the file into blocks
of 50,000 rows each. The original file will not be affected in any
way: this program reads the large file and writes it line by line into
new files.
You may need to change the path reference and filename to match yours.
Sub CSV_Blocks()
Dim RowCounter As Long
Dim FileCounter As Byte
Dim Lyne As String
Open "c:\LargeCSVFileName.csv" For Input As #1
FileCounter = 1
Open "c:\CSV" & FileCounter & ".csv" For Output As #2
Do While Not EOF(1)
Line Input #1, Lyne
Print #2, Lyne
RowCounter = RowCounter + 1
If RowCounter = 50000 Then
RowCounter = 0
Close #2
FileCounter = FileCounter + 1
Open "c:\CSV" & FileCounter & ".csv" For Output As #2
End If
Loop
Close #1
Close #2
End Sub
|