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
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Puertorekinsam

Active Member
Joined
Oct 8, 2005
Messages
287
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,213
Messages
5,594,874
Members
413,945
Latest member
V51773

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