Creating a Macro that sorts data into seperate sheets.

Victor Lopez 41 Reputation points
2022-06-14T19:59:41.17+00:00

So I'd like to have a macro that shows up as a button. The idea is when I press this button, it takes the data I have and sorts it into different sheets based on a date column. The different sheets would be Past due (So date is before today, Less than 1 month (30 days), and more than 30 days. Is this possible and how would I go about this.

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
1,955 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. John Korchok 3,121 Reputation points
    2022-06-15T01:27:14.127+00:00

    To do it yourself, start by searching on terms like VBA move data to worksheets based on date. Those search results will give you a starting point. Then when you need help debugging the details, post here for help.

    No comments

  2. Victor Lopez 41 Reputation points
    2022-06-15T16:31:07.323+00:00

    Attached are 2 images of my current sheets. The goal is to have it sort into separate sheets the data based on how far away the due date is vs todays date, the following code I use was able to do that but for the Students grades, but anytime I try to do it for the date it doesn't recognize the numbers besides -1. I used a cell formula to give me a value for how many months away the date is vs todays date.

    Sub SplitandFilterSheet()

    Dim Splitcode As Range
    Sheets("Master").Select
    Set Splitcode = Range("Splitcode")

    For Each cell In Splitcode
    Sheets("Master").Copy After:=Worksheets(Sheets.Count)
    ActiveSheet.Name = cell.Value

    With ActiveWorkbook.Sheets(cell.Value).Range("MasterData")
    .AutoFilter Field:=5, Criteria1:="<>" & cell.Value, Operator:=xlFilterValues
    .Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    End With

    ActiveSheet.AutoFilter.ShowAllData
    Next cell
    End Sub

    211783-master.jpg211690-splitcell.jpg

    No comments