Share via

Automatic Sorting by Date

Anonymous
2017-11-01T14:29:47+00:00

Hello,

I am creating a list of tasks with the date it must be accomplished by in column B. What I want to happen is that anytime a task is entered and I type the date in column B, for that row to automatically sort in chronological order, with the soonest date at the top and farthest at the bottom. This should happen anytime a new date is entered OR changed.

If a task does not have a date, it should list at the bottom.

I have data in columns A-E, so the range I need sorted is A1:E150

I have headers in row A that should never move.

I believe this is done by using a macro under "view code" but I have not been able to get it to work from the videos I have seen. Please let me know if you can help.

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

Answer accepted by question author

Vijay A. Verma 104.9K Reputation points Volunteer Moderator
2017-11-01T15:03:00+00:00

I have uploaded the workbook with macro to https://1drv.ms/x/s!Akd5y6ruJhvhiggnTeiHJVAyIvE5

For your reference, below are the steps which I have undertaken

  1. Make a backup of your workbook.
  2. Open your workbook and ALT+F11
  3. Locate your Workbook name in Project Explorer Window
  4. Double click on your worksheet name
  5. Copy paste the Macro code given below
  6. Save your file as .xlsm Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ExitSub Application.EnableEvents = False If Intersect(Target, Me.Columns("B")) Is Nothing Then GoTo ExitSub Me.UsedRange.Sort Key1:=Range("B1"), order1:=xlAscending, Header:=xlYes ExitSub: Application.EnableEvents = True End Sub

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-11-01T15:24:32+00:00

    Thank you! It works perfectly.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-11-01T14:48:41+00:00

    Great, thank you!

    You can find it at the link below. I left the dates in.

    https://drive.google.com/open?id=0BzivkuXJZB\_SQ2F0YTNzUi1OSnc

    Was this answer helpful?

    0 comments No comments
  3. Vijay A. Verma 104.9K Reputation points Volunteer Moderator
    2017-11-01T14:33:58+00:00

    I can create the macro for you. For this, I would need your workbook. Could you please upload a sample workbook sans confidential data to Onedrive / Googledrive / Box / Dropbox or any other file host and share the link? It will help us to give prompt and high quality solution.

    Was this answer helpful?

    0 comments No comments