+ Reply to Thread
Results 1 to 8 of 8

Need to split excel file with header into smaller files with same headers in excel

  1. #1
    Registered User
    Join Date
    05-13-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need to split excel file with header into smaller files with same headers in excel

    Hi,
    I have an excel file with over 500,000 and need to split it into separate files of 50,000 records in each file. I also need the header to remain the same for each of the file. I am not good at VBA or macros. can anyone help please as I have been trying for two days now to do this.
    Thanks
    Mo

  2. #2
    Registered User
    Join Date
    05-16-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Need to split excel file with header into smaller files with same headers in excel

    I also need answere to this if possible

  3. #3
    Registered User
    Join Date
    05-16-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Need to split excel file with header into smaller files with same headers in excel

    Sub Macro1()
    Dim lTop As Long, lBottom, lCopy As Long
    Dim LastRow As Long, LastCol As Long
    Dim wbNew As Workbook, sPath As String

    sPath = ThisWorkbook.Path
    With ThisWorkbook.Sheets(1)
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    lTop = 2
    Do
    lBottom = lTop + 20000
    If lBottom > LastRow Then lBottom = LastRow
    lCopy = lCopy + 1

    Set wbNew = Workbooks.Add
    .Range(.Cells(1, 1), .Cells(1, LastCol)).Copy
    wbNew.Sheets(1).Range("A1").PasteSpecial
    .Range(.Cells(lTop, 1), .Cells(lBottom, LastCol)).Copy
    wbNew.Sheets(1).Range("A2").PasteSpecial

    wbNew.Close SaveChanges:=True, FileName:=sPath & "\Split " & lCopy & " Rows " & lTop & "-" & lBottom
    lTop = lBottom + 1
    Loop While lTop <= LastRow
    End With
    End Sub

  4. #4
    Registered User
    Join Date
    05-16-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Need to split excel file with header into smaller files with same headers in excel

    I cannot get the headers to go onto next page thou ..Can anyone help on this please

  5. #5
    Registered User
    Join Date
    05-13-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    3

    Arrow Re: Need to split excel file with header into smaller files with same headers in excel

    The macro provided by KERRY2277has done exactly what my request was including the heders. Thank you for the assistance KERRY2277 you have made my day.
    I now realised that I want the NEWto be created without any headers and must be in csv format. is this osmething easily done or do I need to log another request?
    Thanks for you generous help on this topic.
    Last edited by mnamaz; 05-20-2013 at 06:58 AM. Reason: Clarity

  6. #6
    Registered User
    Join Date
    05-16-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Need to split excel file with header into smaller files with same headers in excel

    Hey no you only have to save and put in csv instead of save using same name and under save as type CSV (*CSV) as the drop down options

  7. #7
    Registered User
    Join Date
    05-13-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need to split excel file with header into smaller files with same headers in excel

    I am not sure I follow what to do. can you simplify it please
    i did the following:
    1.I removed the header from the original file and save it as a .csv file
    2. I then saved the makro is Visual Basic from the Developer tab
    3. I run the macro, it creates multiple files but it then uses the first row as the header for each file.
    Last edited by mnamaz; 05-20-2013 at 12:10 PM.

  8. #8
    Registered User
    Join Date
    12-02-2013
    Location
    Los Angeles
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Need to split excel file with header into smaller files with same headers in excel

    HI there
    I am a newbie here ,and i am new to excel.I have encountered the same problem.I want to split the excel files into two parts.And i have googled a code to do that:
    /// <summary>
    /// Split an Excel document into two sub-documents.
    /// </summary>
    /// <param name="originalDocument"></param>
    /// <param name="pageIdx"></param>
    public void splitPDFDocument(String sourceFilePath,List<String>destnsPath, int pageIdx)
    {
    ExcelDocument.SplitDocument(sourceFilePath, pageIdx, destnsPath);
    }
    But it display nothing.What's wrong with my code?Is there any excel processing program which supports to do that directly?Thanks for any suggestion.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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