+ Reply to Thread
Results 1 to 12 of 12

VBA Code to Seperate a Column into Worksheets By Date Column

  1. #1
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    VBA Code to Seperate a Column into Worksheets By Date Column

    I have a list of data that has a specific date value for each row, and I want to separate the data by date using VBA. I would like to create a new worksheet for each date found and paste the ENTIRE ROW to the created worksheet based on date. I know this is going to create a lot of worksheets, but that's ok -- because the next step is analyzing the time column to break the data down further into Day/Night based on time.
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA Code to Seperate a Column into Worksheets By Date Column

    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    According to your attachment a VBA demonstration as a beginner starter to paste to the Sheet13 (Sheet1) worksheet module :

    PHP Code: 
    Sub Demo1()
            
    Dim VWS$
            
    Application.ScreenUpdating False
        With 
    [A1].CurrentRegion
               
    .Columns(2).AdvancedFilter 2, , [K1], True
                V 
    = [K1].CurrentRegion.Rows.Count 1
                V 
    Application.Small([K2].Resize(V).Value2Evaluate("ROW(1:" ")"))
            For 
    Each W In V
                
    [K2].Value2 W:  Format$(W"mm-dd-yyyy")
                If 
    Evaluate("ISREF('" "'!A1)"Then Sheets(S).UsedRange.Clear Else Sheets.Add(, Sheets(Sheets.Count)).Name S
               
    .AdvancedFilter 2, [K1:K2], Sheets(S).[A1]
            
    Next
        End With
            
    [K1].CurrentRegion.Clear
            Application
    .ScreenUpdating True
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 06-21-2021 at 10:49 AM.

  4. #4
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    Re: Hi ! Try this !

    Both solutions work great. One question for Marc L --- How can I get this to copy and paste the entire row. My sample sheet didnt have the 6 other columns with data included and I need to include that data in the new sheet along with the filtered result

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: VBA Code to Seperate a Column into Worksheets By Date Column


    It's what happens when the attachment does not well reflect the real workbook …
    My demonstration copies all the contiguous data so not a concern if there is no blank column between data,
    but in case of non contiguous data you may use Resize or UsedRange statement …

  6. #6
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    Re: VBA Code to Seperate a Column into Worksheets By Date Column

    Yes that's absolutely 100% my fault for not uploading an accurate portrayal of the data. Thank you for taking the time to help, Marc. Appreciate it.

  7. #7
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    Re: VBA Code to Seperate a Column into Worksheets By Date Column

    I just need it to bring the information in columns A, B, & D to the new workbook it creates based on the date. There will be no blank rows in the date column, I am looking for/correcting for that prior to running this routine.

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA Code to Seperate a Column into Worksheets By Date Column

    For my code...
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  9. #9
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,308

    Re: VBA Code to Seperate a Column into Worksheets By Date Column

    Another possibility...
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA Code to Seperate a Column into Worksheets By Date Column


    Quote Originally Posted by dburge07 View Post
    I just need it to bring the information in columns A, B, & D to the new workbook it creates based on the date.
    If still in need attach the source workbook and the expected result 'new workbook' accordingly …

  11. #11
    Registered User
    Join Date
    05-25-2021
    Location
    Michigan, US
    MS-Off Ver
    MS 365
    Posts
    37

    Re: VBA Code to Seperate a Column into Worksheets By Date Column

    Works perfectly.

    All 3 solutions = great. Thanks a ton!

  12. #12
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: VBA Code to Seperate a Column into Worksheets By Date Column

    ......................
    Thanks.png

+ 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. Export worksheets in a workbook to seperate files keeping Column C hidden
    By Sgligori in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2015, 01:30 PM
  2. Microsoft Excel Query report , Sum prior yr Depr by date in Seperate column
    By Bitto in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 02-11-2014, 11:38 AM
  3. VBA code to seperate the data into different sheet based on column 4
    By acong in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2013, 05:31 AM
  4. Replies: 13
    Last Post: 07-03-2013, 07:03 AM
  5. Sort on one column into seperate worksheets
    By omarq in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2010, 11:03 AM
  6. Replies: 3
    Last Post: 08-18-2007, 01:59 AM
  7. creating a date column from seperate data
    By T.O. in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-20-2005, 09:30 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