Regarding splitting the files

sekharsapcrm26

New Member
Joined
Jul 1, 2015
Messages
1
Dear Experts ,

Can you please help me how here.

I have a excel file which contains of 50 thousand records data. Now I want to convert this file into notepad but every notepad file should have limit of 5000 records only.like that I should get 10 files.
Please help me in this issue , is there any way to do .

Regards,
rajasekhar
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try this:

Code:
Sub saverecords()


Dim wb As Workbook
Dim ws As Worksheet, ws1 As Worksheet
Set ws = ActiveSheet
Set wb = ThisWorkbook
MyDir = ThisWorkbook.FullName
MyType = ThisWorkbook.FileFormat

x = InStrRev(MyDir, "\")


Application.DisplayAlerts = False
For i = 1 To 50000 Step 5000
Set ws1 = ThisWorkbook.Sheets.Add
ws.Range(ws.Rows(i), ws.Rows(i + 4999)).Copy ws1.Cells(1, 1)

ws1.SaveAs Left(MyDir, x) & i & "_to_" & (i + 4999) & ".txt", xlTextWindows
ws1.Delete
Next
ws.Activate

wb.SaveAs MyDir, MyType
Application.DisplayAlerts = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,986
Members
449,058
Latest member
oculus

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
Back
Top