Divide Database Into Smaller Files with 200 lines each

Gamermatt

Board Regular
Joined
May 14, 2009
Messages
186
Hello,

I have a very large database, and I need to divide it into smaller files of 200 lines each. So, every 200 lines there should be a new file saved. Is there a way to automate this, and save each smaller database as a csv file?

Matt
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
OK.

I think the task can be broken down into 3 chunks.

1) Moving the top 200 lines into a separate worksheet, and saving that worksheet by itself as a *.csv file.

2) Automating the naming of the file so that it increments in the way you have described.

3) Looping through (1) and (2) until you get to the bottom of your data, then stopping.

Part 1 is easy, you should get workable code by using the macro recorder while you do the job manually.

Part 2 is do-able, but a little beyond me right now, but try searching the board using terms like vba, file-name, and so on.
For example, I found this thread, which looks like it might be useful (though I haven't tested it myself).
http://www.mrexcel.com/forum/showthread.php?t=229446&highlight=vba+increment+file-name

This thread also deals with part (3).
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,424
Members
452,914
Latest member
echoix

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