Help with Macro to Automatically Sort Excel Sheet by column with colors as data entered

Anonymous
2024-01-15T18:59:16+00:00

I have an excel sheet that I created that is like a task list. I created a column which allows for me to enter the Status.... It has conditional formatting which will change it to a color assigned to the word for that status. I also created a custom sort which will sort them where all the "in progress" goes to the top, then "waiting on someone" then "haven't started" etc....

Question: I would like them to automatically sort by that custom sort as I fill out the data, so i don't have to keep doing the custom sort each time.

Screenshot attached.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. HansV 462.4K Reputation points MVP Volunteer Moderator
    2024-01-15T20:01:37+00:00

    Do you really need the data to be sorted as they are entered? It's rather disconcerting when a row moves out of sight the moment you enter a status.

    I'd prefer to have the sheet be sorted when it is activated.

    0 comments No comments
  2. Anonymous
    2024-01-15T20:34:24+00:00

    I don't need it to but really the status is usually the last part I enter... the other columns don't always get filled in as they are optional. I guess I would just want to have the option for it to automatically sort and if I found it annoying I would undo it.

    I don't even know if its possible.

    0 comments No comments
  3. HansV 462.4K Reputation points MVP Volunteer Moderator
    2024-01-15T21:03:15+00:00

    Right-click the sheet tab.

    Select 'View Code' from the context menu.

    Copy the code listed below into the worksheet module.

    Switch back to Excel.

    Save the workbook as a macro-enabled workbook (*.xlsm).

    You'll have to allow macros when you open the workbook.

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Range("B2:B" & Rows.Count), Target) Is Nothing Then
            Application.ScreenUpdating = False
            Application.EnableEvents = False
            Range("A1").CurrentRegion.Sort Key1:=Range("B1"), Header:=xlYes, _
                OrderCustom:=Application.CustomListCount
            Application.EnableEvents = True
            Application.ScreenUpdating = True
        End If
    End Sub
    

    Remark: this code assumes that the custom list "In Progress, ..." is the last one in the list of custom sort orders (File > Options > Advanced > Custom Lists...). If it's not the last one, replace Application.CustomListCount with the index number of the one you want to use in that list.

    0 comments No comments
  4. Anonymous
    2024-02-21T15:11:33+00:00

    Is there a way to do this so it will custom sort but in a custom order? I re-wrote your code for a similar item I am trying to accomplish from the above. It worked but it is sorting based on alphabetical order and I want it to be a custom order.

    0 comments No comments