+ Reply to Thread
Results 1 to 12 of 12

VBA to split 1 file into multiple files

  1. #1
    Registered User
    Join Date
    08-26-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    19

    VBA to split 1 file into multiple files

    Hi guys,

    I need help for making a code to split my master file into multiple files.

    My data :

    - My data is from A2 to F601
    - A1:F1 is the header

    My requirements :

    - I need a pop up message " how many data per batch ", and when i type like for example 200, there will be 3 excel files in my Import folder ( located in the same folder with my master file )
    - The 3 files will have a name and the data { 1st file = File1to200 (containing data of master file from row A2:F201) , 2nd file = File201to400 (data from row A202:F401, 3rd file = File401to600 (data from row A402:F601 } , in short the data will be 200 rows for each file

    It will be really helpful if some1 can help me in this problem, i will be glad to provide sample data or further explanation if necessary.
    Any kind of help will be appreciated ( The code, an explanation to make the code, or a website that can help me to make the code )

    Thanks in advance guys

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to split 1 file into multiple files

    Maybe:

    Please Login or Register  to view this content.
    You will need to change the file path.

  3. #3
    Registered User
    Join Date
    08-26-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA to split 1 file into multiple files

    Hi John,

    Thank you so much for helping me again , really appreaciate it man. I tried the code and it indeed split the data into 3 file but there are some several problem that i wish you can help me with again due to my lack of knowledge about coding for now.

    1. The 3 file that comes out are in excel 2003, and i actually need excel 2010, i tried to change this part of the code
    Please Login or Register  to view this content.
    into .xlsx but it didnt work.
    2. I need the 3 file to be saved and closed at the same time ( for now the 3 files are all open when i run the code )
    So it will be like when i click the button, the file is just showed up in the folder
    3. and the last thing is when i enter 100 into the inputbox, it indeed split the data 100 each file but there are just 3 files in total, it suppose to become 6 files.( Is this possible?)

    Thank you so much for the help.

  4. #4
    Registered User
    Join Date
    08-26-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA to split 1 file into multiple files

    Hi John,

    Sorry, nevermind about the 1st problem about excel 2010 format, i got that part already, for the other problem can you help me?

    Will be really glad if someone else can also share some knowledge in this matter . Thanks

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to split 1 file into multiple files

    What determines how files are to be created? In Post 1, you say 3. In Post 3, you say 6.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to split 1 file into multiple files

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-26-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA to split 1 file into multiple files

    Hi John,

    Im sorry if i didn't explain it clearly, what i mean before is my data is 600 rows ( this is just for example because the data always varies everytime ) , so when the pop up show up and i enter for example 100 ( this means how many rows per file ). it will create 6 files for me because 1 file contain 100 rows.

    Example :
    1. I type 250 , it become 3 files ( the 3rd file only contain 100 data because the 1st 2 file contain 250 data each )
    2. I type 50, it become 12 files

    Please ask me if there is still anything unclear. Thanks

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to split 1 file into multiple files

    I'm not certain I understand but try

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-26-2013
    Location
    Indonesia
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VBA to split 1 file into multiple files

    Hi John,

    Sorry for the late reply and thank you so much for all your help. The code works perfect, really appreciate it. Thanks man

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to split 1 file into multiple files

    You're welcome. Glad to help out and thanks for the feedback.

  11. #11
    Registered User
    Join Date
    09-05-2013
    Location
    Charlotte, North Carolina
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: VBA to split 1 file into multiple files

    This is a great macro. Is there any way to modify it so that the first row is included in every new workbook?

    Thanks,
    Marion

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to split 1 file into multiple files

    Hi Marion:

    Welcome to the Forum. For furture reference please comply with Forum Rule No. 2. BTW the macro already copies the first row of the activesheet to Sheet1 of each newly created workbook.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Split Excel file into multiple files based on number of rows
    By kingtut86 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2013, 03:38 PM
  2. Split single Excel file into multiple files
    By Michael_O in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2012, 06:27 AM
  3. [SOLVED] Split Large Excel file to multiple excel files and possible save the files
    By EnzioL in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-20-2012, 03:28 AM
  4. Split a file into multiple files
    By bkormoski in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-09-2012, 03:38 PM
  5. Split excel file into multiple files by lines
    By roger212 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2011, 04:46 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1