+ Reply to Thread
Results 1 to 15 of 15

Can I split up an excel spreadsheet into multiple files by rows?

  1. #1
    seespot
    Guest

    Can I split up an excel spreadsheet into multiple files by rows?

    I have an excel spread sheet of many many rows and I would like to split
    every row out into its own file. Is there an easy way to do this?

  2. #2
    Registered User
    Join Date
    01-26-2005
    Posts
    11
    Give us an example of one of your rows. What are your files going to contain.

  3. #3
    Dave Peterson
    Guest

    Re: Can I split up an excel spreadsheet into multiple files by rows?

    And do you want those files saved as .xls files or .txt files (or something
    else)?

    seespot wrote:
    >
    > I have an excel spread sheet of many many rows and I would like to split
    > every row out into its own file. Is there an easy way to do this?


    --

    Dave Peterson

  4. #4
    seespot
    Guest

    Re: Can I split up an excel spreadsheet into multiple files by row

    Each row is made up of numeric and text data in approximately 100 cells. I
    would like to see each row in a new .csv of its own.

    "Dave Peterson" wrote:

    > And do you want those files saved as .xls files or .txt files (or something
    > else)?
    >
    > seespot wrote:
    > >
    > > I have an excel spread sheet of many many rows and I would like to split
    > > every row out into its own file. Is there an easy way to do this?

    >
    > --
    >
    > Dave Peterson
    >


  5. #5
    Dave Peterson
    Guest

    Re: Can I split up an excel spreadsheet into multiple files by row

    One way is with a macro:

    Option Explicit
    Sub testme()

    Dim curWks As Worksheet
    Dim newWks As Worksheet

    Dim iRow As Long
    Dim FirstRow As Long
    Dim LastRow As Long

    Set curWks = Worksheets("sheet1")
    Set newWks = Workbooks.Add(1).Worksheets(1)

    With curWks
    FirstRow = 1
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

    For iRow = FirstRow To LastRow
    .Rows(iRow).Copy
    With newWks.Range("A1")
    .PasteSpecial Paste:=xlPasteValues
    .PasteSpecial Paste:=xlPasteFormats
    End With
    newWks.Parent.SaveAs _
    Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    FileFormat:=xlCSV
    Next iRow
    End With

    newWks.Parent.Close savechanges:=False

    End Sub

    This routine expects to have an existing folder named c:\temp. It creates files
    named ####.csv based on the row number.

    If you run this a second time, you'll want to clean up that folder first--else
    you'll be answer yes/no to each of the overwrite prompts.

    I figure it's a safe way not to destroy important existing data.


    If you're new to macros, you may want to read David McRitchie's intro at:
    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    seespot wrote:
    >
    > Each row is made up of numeric and text data in approximately 100 cells. I
    > would like to see each row in a new .csv of its own.
    >
    > "Dave Peterson" wrote:
    >
    > > And do you want those files saved as .xls files or .txt files (or something
    > > else)?
    > >
    > > seespot wrote:
    > > >
    > > > I have an excel spread sheet of many many rows and I would like to split
    > > > every row out into its own file. Is there an easy way to do this?

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

  6. #6
    seespot
    Guest

    Re: Can I split up an excel spreadsheet into multiple files by row

    Dave,

    That is great. Thanks alot. I missed one thing though; row one is a header
    row that needs to exist in every file as well. So... I need row one and row
    two in the first file, then row one and row three in the next file, etc.

    Can you help?

    "Dave Peterson" wrote:

    > One way is with a macro:
    >
    > Option Explicit
    > Sub testme()
    >
    > Dim curWks As Worksheet
    > Dim newWks As Worksheet
    >
    > Dim iRow As Long
    > Dim FirstRow As Long
    > Dim LastRow As Long
    >
    > Set curWks = Worksheets("sheet1")
    > Set newWks = Workbooks.Add(1).Worksheets(1)
    >
    > With curWks
    > FirstRow = 1
    > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    >
    > For iRow = FirstRow To LastRow
    > .Rows(iRow).Copy
    > With newWks.Range("A1")
    > .PasteSpecial Paste:=xlPasteValues
    > .PasteSpecial Paste:=xlPasteFormats
    > End With
    > newWks.Parent.SaveAs _
    > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > FileFormat:=xlCSV
    > Next iRow
    > End With
    >
    > newWks.Parent.Close savechanges:=False
    >
    > End Sub
    >
    > This routine expects to have an existing folder named c:\temp. It creates files
    > named ####.csv based on the row number.
    >
    > If you run this a second time, you'll want to clean up that folder first--else
    > you'll be answer yes/no to each of the overwrite prompts.
    >
    > I figure it's a safe way not to destroy important existing data.
    >
    >
    > If you're new to macros, you may want to read David McRitchie's intro at:
    > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >
    > seespot wrote:
    > >
    > > Each row is made up of numeric and text data in approximately 100 cells. I
    > > would like to see each row in a new .csv of its own.
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > And do you want those files saved as .xls files or .txt files (or something
    > > > else)?
    > > >
    > > > seespot wrote:
    > > > >
    > > > > I have an excel spread sheet of many many rows and I would like to split
    > > > > every row out into its own file. Is there an easy way to do this?
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >


  7. #7
    Dave Peterson
    Guest

    Re: Can I split up an excel spreadsheet into multiple files by row

    Option Explicit
    Sub testme()

    Dim curWks As Worksheet
    Dim newWks As Worksheet

    Dim iRow As Long
    Dim FirstRow As Long
    Dim LastRow As Long

    Set curWks = Worksheets("sheet1")
    Set newWks = Workbooks.Add(1).Worksheets(1)

    With curWks
    FirstRow = 2 'headers in row 1
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

    .Rows(1).Copy
    With newWks.Range("A1")
    .PasteSpecial Paste:=xlPasteValues
    .PasteSpecial Paste:=xlPasteFormats
    End With

    For iRow = FirstRow To LastRow
    .Rows(iRow).Copy
    With newWks.Range("a2")
    .PasteSpecial Paste:=xlPasteValues
    .PasteSpecial Paste:=xlPasteFormats
    End With
    newWks.Parent.SaveAs _
    Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    FileFormat:=xlCSV
    Next iRow
    End With

    newWks.Parent.Close savechanges:=False

    End Sub


    seespot wrote:
    >
    > Dave,
    >
    > That is great. Thanks alot. I missed one thing though; row one is a header
    > row that needs to exist in every file as well. So... I need row one and row
    > two in the first file, then row one and row three in the next file, etc.
    >
    > Can you help?
    >
    > "Dave Peterson" wrote:
    >
    > > One way is with a macro:
    > >
    > > Option Explicit
    > > Sub testme()
    > >
    > > Dim curWks As Worksheet
    > > Dim newWks As Worksheet
    > >
    > > Dim iRow As Long
    > > Dim FirstRow As Long
    > > Dim LastRow As Long
    > >
    > > Set curWks = Worksheets("sheet1")
    > > Set newWks = Workbooks.Add(1).Worksheets(1)
    > >
    > > With curWks
    > > FirstRow = 1
    > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > >
    > > For iRow = FirstRow To LastRow
    > > .Rows(iRow).Copy
    > > With newWks.Range("A1")
    > > .PasteSpecial Paste:=xlPasteValues
    > > .PasteSpecial Paste:=xlPasteFormats
    > > End With
    > > newWks.Parent.SaveAs _
    > > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > > FileFormat:=xlCSV
    > > Next iRow
    > > End With
    > >
    > > newWks.Parent.Close savechanges:=False
    > >
    > > End Sub
    > >
    > > This routine expects to have an existing folder named c:\temp. It creates files
    > > named ####.csv based on the row number.
    > >
    > > If you run this a second time, you'll want to clean up that folder first--else
    > > you'll be answer yes/no to each of the overwrite prompts.
    > >
    > > I figure it's a safe way not to destroy important existing data.
    > >
    > >
    > > If you're new to macros, you may want to read David McRitchie's intro at:
    > > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    > >
    > > seespot wrote:
    > > >
    > > > Each row is made up of numeric and text data in approximately 100 cells. I
    > > > would like to see each row in a new .csv of its own.
    > > >
    > > > "Dave Peterson" wrote:
    > > >
    > > > > And do you want those files saved as .xls files or .txt files (or something
    > > > > else)?
    > > > >
    > > > > seespot wrote:
    > > > > >
    > > > > > I have an excel spread sheet of many many rows and I would like to split
    > > > > > every row out into its own file. Is there an easy way to do this?
    > > > >
    > > > > --
    > > > >
    > > > > Dave Peterson
    > > > >

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

  8. #8
    afaubert
    Guest

    Re: Can I split up an excel spreadsheet into multiple files by row

    Dave, I am trying to take a worksheet and split it by the field in the first
    column to create separate spreadsheets ...basically I have a master and want
    to split it out to separate files with a naming convention within the
    worksheet (mgr name) in the worksheet. How can I modify this macro to do
    that. I want to maintain all the formatting/formulas/locked cells from the
    original master worksheet.

    Thanks
    Allison


    "Dave Peterson" wrote:

    > Option Explicit
    > Sub testme()
    >
    > Dim curWks As Worksheet
    > Dim newWks As Worksheet
    >
    > Dim iRow As Long
    > Dim FirstRow As Long
    > Dim LastRow As Long
    >
    > Set curWks = Worksheets("sheet1")
    > Set newWks = Workbooks.Add(1).Worksheets(1)
    >
    > With curWks
    > FirstRow = 2 'headers in row 1
    > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    >
    > .Rows(1).Copy
    > With newWks.Range("A1")
    > .PasteSpecial Paste:=xlPasteValues
    > .PasteSpecial Paste:=xlPasteFormats
    > End With
    >
    > For iRow = FirstRow To LastRow
    > .Rows(iRow).Copy
    > With newWks.Range("a2")
    > .PasteSpecial Paste:=xlPasteValues
    > .PasteSpecial Paste:=xlPasteFormats
    > End With
    > newWks.Parent.SaveAs _
    > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > FileFormat:=xlCSV
    > Next iRow
    > End With
    >
    > newWks.Parent.Close savechanges:=False
    >
    > End Sub
    >
    >
    > seespot wrote:
    > >
    > > Dave,
    > >
    > > That is great. Thanks alot. I missed one thing though; row one is a header
    > > row that needs to exist in every file as well. So... I need row one and row
    > > two in the first file, then row one and row three in the next file, etc.
    > >
    > > Can you help?
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > One way is with a macro:
    > > >
    > > > Option Explicit
    > > > Sub testme()
    > > >
    > > > Dim curWks As Worksheet
    > > > Dim newWks As Worksheet
    > > >
    > > > Dim iRow As Long
    > > > Dim FirstRow As Long
    > > > Dim LastRow As Long
    > > >
    > > > Set curWks = Worksheets("sheet1")
    > > > Set newWks = Workbooks.Add(1).Worksheets(1)
    > > >
    > > > With curWks
    > > > FirstRow = 1
    > > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > > >
    > > > For iRow = FirstRow To LastRow
    > > > .Rows(iRow).Copy
    > > > With newWks.Range("A1")
    > > > .PasteSpecial Paste:=xlPasteValues
    > > > .PasteSpecial Paste:=xlPasteFormats
    > > > End With
    > > > newWks.Parent.SaveAs _
    > > > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > > > FileFormat:=xlCSV
    > > > Next iRow
    > > > End With
    > > >
    > > > newWks.Parent.Close savechanges:=False
    > > >
    > > > End Sub
    > > >
    > > > This routine expects to have an existing folder named c:\temp. It creates files
    > > > named ####.csv based on the row number.
    > > >
    > > > If you run this a second time, you'll want to clean up that folder first--else
    > > > you'll be answer yes/no to each of the overwrite prompts.
    > > >
    > > > I figure it's a safe way not to destroy important existing data.
    > > >
    > > >
    > > > If you're new to macros, you may want to read David McRitchie's intro at:
    > > > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    > > >
    > > > seespot wrote:
    > > > >
    > > > > Each row is made up of numeric and text data in approximately 100 cells. I
    > > > > would like to see each row in a new .csv of its own.
    > > > >
    > > > > "Dave Peterson" wrote:
    > > > >
    > > > > > And do you want those files saved as .xls files or .txt files (or something
    > > > > > else)?
    > > > > >
    > > > > > seespot wrote:
    > > > > > >
    > > > > > > I have an excel spread sheet of many many rows and I would like to split
    > > > > > > every row out into its own file. Is there an easy way to do this?
    > > > > >
    > > > > > --
    > > > > >
    > > > > > Dave Peterson
    > > > > >
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >


  9. #9
    Dave Peterson
    Guest

    Re: Can I split up an excel spreadsheet into multiple files by row

    I don't think I'd use this macro as the basis for what you want.

    But maybe it's already built:

    Debra's site:
    http://www.contextures.com/excelfiles.html

    Create New Sheets from Filtered List -- uses an Advanced Filter to create
    separate sheet of orders for each sales rep visible in a filtered list; macro
    automates the filter. AdvFilterRepFiltered.xls 35 kb

    or

    Update Sheets from Master -- uses an Advanced Filter to send data from
    Master sheet to individual worksheets -- replaces old data with current.
    AdvFilterCity.xls 55 kb

    And Ron de Bruin's easyfilter.
    http://www.rondebruin.nl/easyfilter.htm

    afaubert wrote:
    >
    > Dave, I am trying to take a worksheet and split it by the field in the first
    > column to create separate spreadsheets ...basically I have a master and want
    > to split it out to separate files with a naming convention within the
    > worksheet (mgr name) in the worksheet. How can I modify this macro to do
    > that. I want to maintain all the formatting/formulas/locked cells from the
    > original master worksheet.
    >
    > Thanks
    > Allison
    >
    > "Dave Peterson" wrote:
    >
    > > Option Explicit
    > > Sub testme()
    > >
    > > Dim curWks As Worksheet
    > > Dim newWks As Worksheet
    > >
    > > Dim iRow As Long
    > > Dim FirstRow As Long
    > > Dim LastRow As Long
    > >
    > > Set curWks = Worksheets("sheet1")
    > > Set newWks = Workbooks.Add(1).Worksheets(1)
    > >
    > > With curWks
    > > FirstRow = 2 'headers in row 1
    > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > >
    > > .Rows(1).Copy
    > > With newWks.Range("A1")
    > > .PasteSpecial Paste:=xlPasteValues
    > > .PasteSpecial Paste:=xlPasteFormats
    > > End With
    > >
    > > For iRow = FirstRow To LastRow
    > > .Rows(iRow).Copy
    > > With newWks.Range("a2")
    > > .PasteSpecial Paste:=xlPasteValues
    > > .PasteSpecial Paste:=xlPasteFormats
    > > End With
    > > newWks.Parent.SaveAs _
    > > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > > FileFormat:=xlCSV
    > > Next iRow
    > > End With
    > >
    > > newWks.Parent.Close savechanges:=False
    > >
    > > End Sub
    > >
    > >
    > > seespot wrote:
    > > >
    > > > Dave,
    > > >
    > > > That is great. Thanks alot. I missed one thing though; row one is a header
    > > > row that needs to exist in every file as well. So... I need row one and row
    > > > two in the first file, then row one and row three in the next file, etc.
    > > >
    > > > Can you help?
    > > >
    > > > "Dave Peterson" wrote:
    > > >
    > > > > One way is with a macro:
    > > > >
    > > > > Option Explicit
    > > > > Sub testme()
    > > > >
    > > > > Dim curWks As Worksheet
    > > > > Dim newWks As Worksheet
    > > > >
    > > > > Dim iRow As Long
    > > > > Dim FirstRow As Long
    > > > > Dim LastRow As Long
    > > > >
    > > > > Set curWks = Worksheets("sheet1")
    > > > > Set newWks = Workbooks.Add(1).Worksheets(1)
    > > > >
    > > > > With curWks
    > > > > FirstRow = 1
    > > > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > > > >
    > > > > For iRow = FirstRow To LastRow
    > > > > .Rows(iRow).Copy
    > > > > With newWks.Range("A1")
    > > > > .PasteSpecial Paste:=xlPasteValues
    > > > > .PasteSpecial Paste:=xlPasteFormats
    > > > > End With
    > > > > newWks.Parent.SaveAs _
    > > > > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > > > > FileFormat:=xlCSV
    > > > > Next iRow
    > > > > End With
    > > > >
    > > > > newWks.Parent.Close savechanges:=False
    > > > >
    > > > > End Sub
    > > > >
    > > > > This routine expects to have an existing folder named c:\temp. It creates files
    > > > > named ####.csv based on the row number.
    > > > >
    > > > > If you run this a second time, you'll want to clean up that folder first--else
    > > > > you'll be answer yes/no to each of the overwrite prompts.
    > > > >
    > > > > I figure it's a safe way not to destroy important existing data.
    > > > >
    > > > >
    > > > > If you're new to macros, you may want to read David McRitchie's intro at:
    > > > > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    > > > >
    > > > > seespot wrote:
    > > > > >
    > > > > > Each row is made up of numeric and text data in approximately 100 cells. I
    > > > > > would like to see each row in a new .csv of its own.
    > > > > >
    > > > > > "Dave Peterson" wrote:
    > > > > >
    > > > > > > And do you want those files saved as .xls files or .txt files (or something
    > > > > > > else)?
    > > > > > >
    > > > > > > seespot wrote:
    > > > > > > >
    > > > > > > > I have an excel spread sheet of many many rows and I would like to split
    > > > > > > > every row out into its own file. Is there an easy way to do this?
    > > > > > >
    > > > > > > --
    > > > > > >
    > > > > > > Dave Peterson
    > > > > > >
    > > > >
    > > > > --
    > > > >
    > > > > Dave Peterson
    > > > >

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

  10. #10
    Forum Contributor
    Join Date
    04-28-2013
    Location
    Bangalore
    MS-Off Ver
    Excel 2010
    Posts
    135

    Re: Can I split up an excel spreadsheet into multiple files by row

    Quote Originally Posted by Dave Peterson View Post
    I don't think I'd use this macro as the basis for what you want.

    But maybe it's already built:

    Debra's site:
    http://www.contextures.com/excelfiles.html

    Create New Sheets from Filtered List -- uses an Advanced Filter to create
    separate sheet of orders for each sales rep visible in a filtered list; macro
    automates the filter. AdvFilterRepFiltered.xls 35 kb

    or

    Update Sheets from Master -- uses an Advanced Filter to send data from
    Master sheet to individual worksheets -- replaces old data with current.
    AdvFilterCity.xls 55 kb

    And Ron de Bruin's easyfilter.
    http://www.rondebruin.nl/easyfilter.htm

    afaubert wrote:
    >
    > Dave, I am trying to take a worksheet and split it by the field in the first
    > column to create separate spreadsheets ...basically I have a master and want
    > to split it out to separate files with a naming convention within the
    > worksheet (mgr name) in the worksheet. How can I modify this macro to do
    > that. I want to maintain all the formatting/formulas/locked cells from the
    > original master worksheet.
    >
    > Thanks
    > Allison
    >
    > "Dave Peterson" wrote:
    >
    > > Option Explicit
    > > Sub testme()
    > >
    > > Dim curWks As Worksheet
    > > Dim newWks As Worksheet
    > >
    > > Dim iRow As Long
    > > Dim FirstRow As Long
    > > Dim LastRow As Long
    > >
    > > Set curWks = Worksheets("sheet1")
    > > Set newWks = Workbooks.Add(1).Worksheets(1)
    > >
    > > With curWks
    > > FirstRow = 2 'headers in row 1
    > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > >
    > > .Rows(1).Copy
    > > With newWks.Range("A1")
    > > .PasteSpecial Paste:=xlPasteValues
    > > .PasteSpecial Paste:=xlPasteFormats
    > > End With
    > >
    > > For iRow = FirstRow To LastRow
    > > .Rows(iRow).Copy
    > > With newWks.Range("a2")
    > > .PasteSpecial Paste:=xlPasteValues
    > > .PasteSpecial Paste:=xlPasteFormats
    > > End With
    > > newWks.Parent.SaveAs _
    > > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > > FileFormat:=xlCSV
    > > Next iRow
    > > End With
    > >
    > > newWks.Parent.Close savechanges:=False
    > >
    > > End Sub
    > >
    > >
    > > seespot wrote:
    > > >
    > > > Dave,
    > > >
    > > > That is great. Thanks alot. I missed one thing though; row one is a header
    > > > row that needs to exist in every file as well. So... I need row one and row
    > > > two in the first file, then row one and row three in the next file, etc.
    > > >
    > > > Can you help?
    > > >
    > > > "Dave Peterson" wrote:
    > > >
    > > > > One way is with a macro:
    > > > >
    > > > > Option Explicit
    > > > > Sub testme()
    > > > >
    > > > > Dim curWks As Worksheet
    > > > > Dim newWks As Worksheet
    > > > >
    > > > > Dim iRow As Long
    > > > > Dim FirstRow As Long
    > > > > Dim LastRow As Long
    > > > >
    > > > > Set curWks = Worksheets("sheet1")
    > > > > Set newWks = Workbooks.Add(1).Worksheets(1)
    > > > >
    > > > > With curWks
    > > > > FirstRow = 1
    > > > > LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    > > > >
    > > > > For iRow = FirstRow To LastRow
    > > > > .Rows(iRow).Copy
    > > > > With newWks.Range("A1")
    > > > > .PasteSpecial Paste:=xlPasteValues
    > > > > .PasteSpecial Paste:=xlPasteFormats
    > > > > End With
    > > > > newWks.Parent.SaveAs _
    > > > > Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    > > > > FileFormat:=xlCSV
    > > > > Next iRow
    > > > > End With
    > > > >
    > > > > newWks.Parent.Close savechanges:=False
    > > > >
    > > > > End Sub
    > > > >
    > > > > This routine expects to have an existing folder named c:\temp. It creates files
    > > > > named ####.csv based on the row number.
    > > > >
    > > > > If you run this a second time, you'll want to clean up that folder first--else
    > > > > you'll be answer yes/no to each of the overwrite prompts.
    > > > >
    > > > > I figure it's a safe way not to destroy important existing data.
    > > > >
    > > > >
    > > > > If you're new to macros, you may want to read David McRitchie's intro at:
    > > > > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    > > > >
    > > > > seespot wrote:
    > > > > >
    > > > > > Each row is made up of numeric and text data in approximately 100 cells. I
    > > > > > would like to see each row in a new .csv of its own.
    > > > > >
    > > > > > "Dave Peterson" wrote:
    > > > > >
    > > > > > > And do you want those files saved as .xls files or .txt files (or something
    > > > > > > else)?
    > > > > > >
    > > > > > > seespot wrote:
    > > > > > > >
    > > > > > > > I have an excel spread sheet of many many rows and I would like to split
    > > > > > > > every row out into its own file. Is there an easy way to do this?
    > > > > > >
    > > > > > > --
    > > > > > >
    > > > > > > Dave Peterson
    > > > > > >
    > > > >
    > > > > --
    > > > >
    > > > > Dave Peterson
    > > > >

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

    Is there a way to keep header as common in every sheet and split rows if it exceed more than 2000 rows in to different sheet and so on!

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Can I split up an excel spreadsheet into multiple files by rows?

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  12. #12
    Registered User
    Join Date
    08-28-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2007
    Posts
    3

    Re: Can I split up an excel spreadsheet into multiple files by row

    Quote Originally Posted by Dave Peterson View Post
    One way is with a macro:

    Option Explicit
    Sub testme()

    Dim curWks As Worksheet
    Dim newWks As Worksheet

    Dim iRow As Long
    Dim FirstRow As Long
    Dim LastRow As Long

    Set curWks = Worksheets("sheet1")
    Set newWks = Workbooks.Add(1).Worksheets(1)

    With curWks
    FirstRow = 1
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

    For iRow = FirstRow To LastRow
    .Rows(iRow).Copy
    With newWks.Range("A1")
    .PasteSpecial Paste:=xlPasteValues
    .PasteSpecial Paste:=xlPasteFormats
    End With
    newWks.Parent.SaveAs _
    Filename:="C:\temp\" & Format(iRow, "0000") & ".csv", _
    FileFormat:=xlCSV
    Next iRow
    End With

    newWks.Parent.Close savechanges:=False

    End Sub

    This routine expects to have an existing folder named c:\temp. It creates files
    named ####.csv based on the row number.

    If you run this a second time, you'll want to clean up that folder first--else
    you'll be answer yes/no to each of the overwrite prompts.

    I figure it's a safe way not to destroy important existing data.


    If you're new to macros, you may want to read David McRitchie's intro at:
    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    seespot wrote:
    >
    > Each row is made up of numeric and text data in approximately 100 cells. I
    > would like to see each row in a new .csv of its own.
    >
    > "Dave Peterson" wrote:
    >
    > > And do you want those files saved as .xls files or .txt files (or something
    > > else)?
    > >
    > > seespot wrote:
    > > >
    > > > I have an excel spread sheet of many many rows and I would like to split
    > > > every row out into its own file. Is there an easy way to do this?

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson
    Dave, thanks for this response. How do I modify this macro to separate the original file to multiple files but not 1 row each (plus the top row) but indicate the exact number of rows in addition to that top row? For instance, I have 5001 rows file and want to create multiple files 1001 rows each with the same top row.

    Thanks again for your help!

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,369

    Re: Can I split up an excel spreadsheet into multiple files by rows?

    Unfortunately you need to post your question in a new thread, as it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  14. #14
    Registered User
    Join Date
    08-28-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2007
    Posts
    3

    Re: Can I split up an excel spreadsheet into multiple files by rows?

    Oh, I've just found the answer to my question here:
    https://www.magnetismsolutions.com/b...ata-migrations
    Tried it and it does what I need as described above, so I am good now.

  15. #15
    Registered User
    Join Date
    08-28-2017
    Location
    Bellevue, WA
    MS-Off Ver
    2007
    Posts
    3

    Re: Can I split up an excel spreadsheet into multiple files by rows?

    Will do next time, thanks for letting me know.

+ 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