Split one large excel file into many small text files

super0890

New Member
Joined
Feb 18, 2011
Messages
1
I would like to split an excel file of 60,000 rows into small text files (.txt) of 5000 rows (or lines) Is there any way I can split one large excel file into many text files?

I could find a macro that creates a text file from Excel data on another forum, but some how it doesn't seem to work in excel 2007

Code:
Sub Export()
Dim objFs As Object
Dim objText As Object
Dim strData As String
Dim n As Integer

Set objFs = CreateObject("Scripting.FileSystemObject")

'create the text file with Path & text filename
Set objText = objFs.CreateTextFile("C:\MyExcelData.txt", 1)

'create a string from the data
For n = 0 To 20
    strData = strData & ActiveSheet.Range("B2").Offset(n, 0).Text & vbCrLf
Next n

'write the string to the text file
objText.WriteLine (strData)

'close the text file
objText.Close

'remove the file system object
Set objFs = Nothing
End Sub</pre>

Any help? anyone?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,143,654
Messages
5,720,109
Members
422,266
Latest member
Mattyw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top