Split excel spreadsheet into separate files based on date columnExcel - Change cell colour based on a date in...

What does it take to become a wilderness skills guide as a business?

Is there a logarithm base for which the logarithm becomes an identity function?

Too soon for a plot twist?

Did Amazon pay $0 in taxes last year?

How does learning spells work when leveling a multiclass character?

Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?

Unfamiliar notation in Diabelli's "Duet in D" for piano

Insult for someone who "doesn't know anything"

How can I have x-axis ticks that show ticks scaled in powers of ten?

What is the oldest European royal house?

School performs periodic password audits. Is my password compromised?

PTIJ: Sport in the Torah

Does an unused member variable take up memory?

What is Tony Stark injecting into himself in Iron Man 3?

Was this cameo in Captain Marvel computer generated?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

I am the person who abides by rules but breaks the rules . Who am I

Why restrict private health insurance?

3.5% Interest Student Loan or use all of my savings on Tuition?

How to install "rounded" brake pads

Can multiple states demand income tax from an LLC?

Why would /etc/passwd be used every time someone executes `ls -l` command?

Why does this boat have a landing pad? (SpaceX's GO Searcher) Any plans for propulsive capsule landings?

Should I file my taxes? No income, unemployed, but paid 2k in student loan interest



Split excel spreadsheet into separate files based on date column


Excel - Change cell colour based on a date in the comment or mixed in with textHow can I split Excel data from one row into multiple rowsCan I split a spreadsheet into multiple files based on a Row in Excel 2013?Remove duplicate rows, and keep newest row based on date columnHow do I split a single row into multiple rows based on quantity in Excel?Split cell data into multiple cellsHow to create text files from excel per column value?How to split multiple worksheets of data by column value and output to separate files?Transpose Stacked Data in One Column to Rows based on Variable Criteria and Unique IdentifiersExcel - Change cell colour based on a date













0















I have an Excel with a lot of rows 20.000+ that I want to split based on the creation date (date only without time) and save as separate files.



The file looks like:
example



Can anyone help me with this. I have tried changing some VBA codes I found on this site but ran against errors that I couldn't solve.










share|improve this question









New contributor




user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 6





    Please share the VBA code that didn't work for you and the error you received.

    – Worthwelle
    10 hours ago











  • Is there a reason you're looking at VBA rather than filtering by date, then copy/cut and pasting the relevant data to another sheet?

    – Alex M
    8 hours ago
















0















I have an Excel with a lot of rows 20.000+ that I want to split based on the creation date (date only without time) and save as separate files.



The file looks like:
example



Can anyone help me with this. I have tried changing some VBA codes I found on this site but ran against errors that I couldn't solve.










share|improve this question









New contributor




user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 6





    Please share the VBA code that didn't work for you and the error you received.

    – Worthwelle
    10 hours ago











  • Is there a reason you're looking at VBA rather than filtering by date, then copy/cut and pasting the relevant data to another sheet?

    – Alex M
    8 hours ago














0












0








0








I have an Excel with a lot of rows 20.000+ that I want to split based on the creation date (date only without time) and save as separate files.



The file looks like:
example



Can anyone help me with this. I have tried changing some VBA codes I found on this site but ran against errors that I couldn't solve.










share|improve this question









New contributor




user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have an Excel with a lot of rows 20.000+ that I want to split based on the creation date (date only without time) and save as separate files.



The file looks like:
example



Can anyone help me with this. I have tried changing some VBA codes I found on this site but ran against errors that I couldn't solve.







microsoft-excel vba






share|improve this question









New contributor




user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 10 hours ago









Worthwelle

2,80331325




2,80331325






New contributor




user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 10 hours ago









user1005845user1005845

6




6




New contributor




user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user1005845 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 6





    Please share the VBA code that didn't work for you and the error you received.

    – Worthwelle
    10 hours ago











  • Is there a reason you're looking at VBA rather than filtering by date, then copy/cut and pasting the relevant data to another sheet?

    – Alex M
    8 hours ago














  • 6





    Please share the VBA code that didn't work for you and the error you received.

    – Worthwelle
    10 hours ago











  • Is there a reason you're looking at VBA rather than filtering by date, then copy/cut and pasting the relevant data to another sheet?

    – Alex M
    8 hours ago








6




6





Please share the VBA code that didn't work for you and the error you received.

– Worthwelle
10 hours ago





Please share the VBA code that didn't work for you and the error you received.

– Worthwelle
10 hours ago













Is there a reason you're looking at VBA rather than filtering by date, then copy/cut and pasting the relevant data to another sheet?

– Alex M
8 hours ago





Is there a reason you're looking at VBA rather than filtering by date, then copy/cut and pasting the relevant data to another sheet?

– Alex M
8 hours ago










1 Answer
1






active

oldest

votes


















0














Thanks to Shirley Zhang.

Original from: (datanumen.com/blogs/2-fast-means-to-split-an-excel-worksheets-contents-into-multiple-workbooks-based-on-a-specific-column) edited by me.



Due to create, edit and save workbooks, it takes a long time to calculate 20.000+ lines. Maybe more than 15 minutes.



Sub SplitSheetDataIntoMultipleWorkbooksBasedOnSpecificColumn()
Dim objWorksheet As Excel.Worksheet
Dim nLastRow, nRow, nNextRow As Integer
Dim strColumnValue As String
Dim objDictionary As Object
Dim varColumnValues As Variant
Dim varColumnValue As Variant
Dim objExcelWorkbook As Excel.Workbook
Dim objSheet As Excel.Worksheet

Dim aCol As String
aCol = "G" '<- Change Source-Column here

On Error GoTo err1
'Speed up a little bit
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.EnableEvents = False
End With

Set objWorksheet = ActiveSheet
nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row

Set objDictionary = CreateObject("Scripting.Dictionary")

For nRow = 2 To nLastRow
'Get the specific Column
'Here my instance is "B" column
'You can change it to your case

'strColumnValue = objWorksheet.Range("B" & nRow).Value
strColumnValue = Format(objWorksheet.Range(aCol & nRow).Value, "mm_dd_yyyy") '<- Set the filter and filename

If objDictionary.Exists(strColumnValue) = False Then
objDictionary.Add strColumnValue, 1
End If
Next

varColumnValues = objDictionary.Keys

For i = LBound(varColumnValues) To UBound(varColumnValues)
varColumnValue = varColumnValues(i)

'Create a new Excel workbook
Set objExcelWorkbook = Excel.Application.Workbooks.Add

Set objSheet = objExcelWorkbook.Sheets(1)
objSheet.Name = objWorksheet.Name

objWorksheet.Rows(1).EntireRow.Copy
objSheet.Activate
objSheet.Range("A1").Select
objSheet.Paste

For nRow = 2 To nLastRow
If CStr(objWorksheet.Range(aCol & nRow).Value) = CStr(varColumnValue) Then
'Copy data with the same column "B" value to new workbook
objWorksheet.Rows(nRow).EntireRow.Copy

nNextRow = objSheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row + 1
objSheet.Range("A" & nNextRow).Select
objSheet.Paste
objSheet.Columns("A:I").AutoFit
End If

Next

objExcelWorkbook.SaveAs (CStr(varColumnValue))

Next

err1:
'Restore slow but necessary settings
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
End With

End Sub





share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    user1005845 is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1412456%2fsplit-excel-spreadsheet-into-separate-files-based-on-date-column%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Thanks to Shirley Zhang.

    Original from: (datanumen.com/blogs/2-fast-means-to-split-an-excel-worksheets-contents-into-multiple-workbooks-based-on-a-specific-column) edited by me.



    Due to create, edit and save workbooks, it takes a long time to calculate 20.000+ lines. Maybe more than 15 minutes.



    Sub SplitSheetDataIntoMultipleWorkbooksBasedOnSpecificColumn()
    Dim objWorksheet As Excel.Worksheet
    Dim nLastRow, nRow, nNextRow As Integer
    Dim strColumnValue As String
    Dim objDictionary As Object
    Dim varColumnValues As Variant
    Dim varColumnValue As Variant
    Dim objExcelWorkbook As Excel.Workbook
    Dim objSheet As Excel.Worksheet

    Dim aCol As String
    aCol = "G" '<- Change Source-Column here

    On Error GoTo err1
    'Speed up a little bit
    With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    .EnableEvents = False
    End With

    Set objWorksheet = ActiveSheet
    nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row

    Set objDictionary = CreateObject("Scripting.Dictionary")

    For nRow = 2 To nLastRow
    'Get the specific Column
    'Here my instance is "B" column
    'You can change it to your case

    'strColumnValue = objWorksheet.Range("B" & nRow).Value
    strColumnValue = Format(objWorksheet.Range(aCol & nRow).Value, "mm_dd_yyyy") '<- Set the filter and filename

    If objDictionary.Exists(strColumnValue) = False Then
    objDictionary.Add strColumnValue, 1
    End If
    Next

    varColumnValues = objDictionary.Keys

    For i = LBound(varColumnValues) To UBound(varColumnValues)
    varColumnValue = varColumnValues(i)

    'Create a new Excel workbook
    Set objExcelWorkbook = Excel.Application.Workbooks.Add

    Set objSheet = objExcelWorkbook.Sheets(1)
    objSheet.Name = objWorksheet.Name

    objWorksheet.Rows(1).EntireRow.Copy
    objSheet.Activate
    objSheet.Range("A1").Select
    objSheet.Paste

    For nRow = 2 To nLastRow
    If CStr(objWorksheet.Range(aCol & nRow).Value) = CStr(varColumnValue) Then
    'Copy data with the same column "B" value to new workbook
    objWorksheet.Rows(nRow).EntireRow.Copy

    nNextRow = objSheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row + 1
    objSheet.Range("A" & nNextRow).Select
    objSheet.Paste
    objSheet.Columns("A:I").AutoFit
    End If

    Next

    objExcelWorkbook.SaveAs (CStr(varColumnValue))

    Next

    err1:
    'Restore slow but necessary settings
    With Application
    .ScreenUpdating = True
    .Calculation = xlCalculationAutomatic
    .EnableEvents = True
    End With

    End Sub





    share|improve this answer






























      0














      Thanks to Shirley Zhang.

      Original from: (datanumen.com/blogs/2-fast-means-to-split-an-excel-worksheets-contents-into-multiple-workbooks-based-on-a-specific-column) edited by me.



      Due to create, edit and save workbooks, it takes a long time to calculate 20.000+ lines. Maybe more than 15 minutes.



      Sub SplitSheetDataIntoMultipleWorkbooksBasedOnSpecificColumn()
      Dim objWorksheet As Excel.Worksheet
      Dim nLastRow, nRow, nNextRow As Integer
      Dim strColumnValue As String
      Dim objDictionary As Object
      Dim varColumnValues As Variant
      Dim varColumnValue As Variant
      Dim objExcelWorkbook As Excel.Workbook
      Dim objSheet As Excel.Worksheet

      Dim aCol As String
      aCol = "G" '<- Change Source-Column here

      On Error GoTo err1
      'Speed up a little bit
      With Application
      .ScreenUpdating = False
      .Calculation = xlCalculationManual
      .EnableEvents = False
      End With

      Set objWorksheet = ActiveSheet
      nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row

      Set objDictionary = CreateObject("Scripting.Dictionary")

      For nRow = 2 To nLastRow
      'Get the specific Column
      'Here my instance is "B" column
      'You can change it to your case

      'strColumnValue = objWorksheet.Range("B" & nRow).Value
      strColumnValue = Format(objWorksheet.Range(aCol & nRow).Value, "mm_dd_yyyy") '<- Set the filter and filename

      If objDictionary.Exists(strColumnValue) = False Then
      objDictionary.Add strColumnValue, 1
      End If
      Next

      varColumnValues = objDictionary.Keys

      For i = LBound(varColumnValues) To UBound(varColumnValues)
      varColumnValue = varColumnValues(i)

      'Create a new Excel workbook
      Set objExcelWorkbook = Excel.Application.Workbooks.Add

      Set objSheet = objExcelWorkbook.Sheets(1)
      objSheet.Name = objWorksheet.Name

      objWorksheet.Rows(1).EntireRow.Copy
      objSheet.Activate
      objSheet.Range("A1").Select
      objSheet.Paste

      For nRow = 2 To nLastRow
      If CStr(objWorksheet.Range(aCol & nRow).Value) = CStr(varColumnValue) Then
      'Copy data with the same column "B" value to new workbook
      objWorksheet.Rows(nRow).EntireRow.Copy

      nNextRow = objSheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row + 1
      objSheet.Range("A" & nNextRow).Select
      objSheet.Paste
      objSheet.Columns("A:I").AutoFit
      End If

      Next

      objExcelWorkbook.SaveAs (CStr(varColumnValue))

      Next

      err1:
      'Restore slow but necessary settings
      With Application
      .ScreenUpdating = True
      .Calculation = xlCalculationAutomatic
      .EnableEvents = True
      End With

      End Sub





      share|improve this answer




























        0












        0








        0







        Thanks to Shirley Zhang.

        Original from: (datanumen.com/blogs/2-fast-means-to-split-an-excel-worksheets-contents-into-multiple-workbooks-based-on-a-specific-column) edited by me.



        Due to create, edit and save workbooks, it takes a long time to calculate 20.000+ lines. Maybe more than 15 minutes.



        Sub SplitSheetDataIntoMultipleWorkbooksBasedOnSpecificColumn()
        Dim objWorksheet As Excel.Worksheet
        Dim nLastRow, nRow, nNextRow As Integer
        Dim strColumnValue As String
        Dim objDictionary As Object
        Dim varColumnValues As Variant
        Dim varColumnValue As Variant
        Dim objExcelWorkbook As Excel.Workbook
        Dim objSheet As Excel.Worksheet

        Dim aCol As String
        aCol = "G" '<- Change Source-Column here

        On Error GoTo err1
        'Speed up a little bit
        With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .EnableEvents = False
        End With

        Set objWorksheet = ActiveSheet
        nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row

        Set objDictionary = CreateObject("Scripting.Dictionary")

        For nRow = 2 To nLastRow
        'Get the specific Column
        'Here my instance is "B" column
        'You can change it to your case

        'strColumnValue = objWorksheet.Range("B" & nRow).Value
        strColumnValue = Format(objWorksheet.Range(aCol & nRow).Value, "mm_dd_yyyy") '<- Set the filter and filename

        If objDictionary.Exists(strColumnValue) = False Then
        objDictionary.Add strColumnValue, 1
        End If
        Next

        varColumnValues = objDictionary.Keys

        For i = LBound(varColumnValues) To UBound(varColumnValues)
        varColumnValue = varColumnValues(i)

        'Create a new Excel workbook
        Set objExcelWorkbook = Excel.Application.Workbooks.Add

        Set objSheet = objExcelWorkbook.Sheets(1)
        objSheet.Name = objWorksheet.Name

        objWorksheet.Rows(1).EntireRow.Copy
        objSheet.Activate
        objSheet.Range("A1").Select
        objSheet.Paste

        For nRow = 2 To nLastRow
        If CStr(objWorksheet.Range(aCol & nRow).Value) = CStr(varColumnValue) Then
        'Copy data with the same column "B" value to new workbook
        objWorksheet.Rows(nRow).EntireRow.Copy

        nNextRow = objSheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row + 1
        objSheet.Range("A" & nNextRow).Select
        objSheet.Paste
        objSheet.Columns("A:I").AutoFit
        End If

        Next

        objExcelWorkbook.SaveAs (CStr(varColumnValue))

        Next

        err1:
        'Restore slow but necessary settings
        With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .EnableEvents = True
        End With

        End Sub





        share|improve this answer















        Thanks to Shirley Zhang.

        Original from: (datanumen.com/blogs/2-fast-means-to-split-an-excel-worksheets-contents-into-multiple-workbooks-based-on-a-specific-column) edited by me.



        Due to create, edit and save workbooks, it takes a long time to calculate 20.000+ lines. Maybe more than 15 minutes.



        Sub SplitSheetDataIntoMultipleWorkbooksBasedOnSpecificColumn()
        Dim objWorksheet As Excel.Worksheet
        Dim nLastRow, nRow, nNextRow As Integer
        Dim strColumnValue As String
        Dim objDictionary As Object
        Dim varColumnValues As Variant
        Dim varColumnValue As Variant
        Dim objExcelWorkbook As Excel.Workbook
        Dim objSheet As Excel.Worksheet

        Dim aCol As String
        aCol = "G" '<- Change Source-Column here

        On Error GoTo err1
        'Speed up a little bit
        With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
        .EnableEvents = False
        End With

        Set objWorksheet = ActiveSheet
        nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row

        Set objDictionary = CreateObject("Scripting.Dictionary")

        For nRow = 2 To nLastRow
        'Get the specific Column
        'Here my instance is "B" column
        'You can change it to your case

        'strColumnValue = objWorksheet.Range("B" & nRow).Value
        strColumnValue = Format(objWorksheet.Range(aCol & nRow).Value, "mm_dd_yyyy") '<- Set the filter and filename

        If objDictionary.Exists(strColumnValue) = False Then
        objDictionary.Add strColumnValue, 1
        End If
        Next

        varColumnValues = objDictionary.Keys

        For i = LBound(varColumnValues) To UBound(varColumnValues)
        varColumnValue = varColumnValues(i)

        'Create a new Excel workbook
        Set objExcelWorkbook = Excel.Application.Workbooks.Add

        Set objSheet = objExcelWorkbook.Sheets(1)
        objSheet.Name = objWorksheet.Name

        objWorksheet.Rows(1).EntireRow.Copy
        objSheet.Activate
        objSheet.Range("A1").Select
        objSheet.Paste

        For nRow = 2 To nLastRow
        If CStr(objWorksheet.Range(aCol & nRow).Value) = CStr(varColumnValue) Then
        'Copy data with the same column "B" value to new workbook
        objWorksheet.Rows(nRow).EntireRow.Copy

        nNextRow = objSheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row + 1
        objSheet.Range("A" & nNextRow).Select
        objSheet.Paste
        objSheet.Columns("A:I").AutoFit
        End If

        Next

        objExcelWorkbook.SaveAs (CStr(varColumnValue))

        Next

        err1:
        'Restore slow but necessary settings
        With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
        .EnableEvents = True
        End With

        End Sub






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 1 hour ago

























        answered 1 hour ago









        busybytebusybyte

        474




        474






















            user1005845 is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            user1005845 is a new contributor. Be nice, and check out our Code of Conduct.













            user1005845 is a new contributor. Be nice, and check out our Code of Conduct.












            user1005845 is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1412456%2fsplit-excel-spreadsheet-into-separate-files-based-on-date-column%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

            Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...