Need help with auto sorting in Excel

Anonymous
2015-09-18T16:29:53+00:00

I need Excel to auto sort smallest to largest descending and pull other cells to the new location as a new time is entered.

In detail:

Column C is time of day for a specific event (in military time) beginning on Row 5.  When a user enters a new event and assigns a time to it, I need that corresponding information to sort into the correct event row.  Below is a capture of the worksheet.

So for instance; The data entered for Event #10 beginning with Cell C14 and ending with Cell I14 would need to move to the row for Event #1 (Cells C5 to I5).  So basically I just need Columns "C" through "I" beginning on row 5 to auto sort based off of the time entered in column C so that the proper Event # is met based off of the time of day that it occurs.  I believe this requires a Macro but I am unfamiliar with those.

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} votes

17 answers

Sort by: Most helpful
  1. Anonymous
    2015-09-28T18:26:03+00:00

    Hi,

    try this...

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    'Sep 28, 2015

    Dim r As Long, c As Long

    If Target.Column <> 1 Or Target.Value <> "Date" Then

    MsgBox "wrong, select <Date> in column A"

    Exit Sub

    End If

    r = Target.CurrentRegion.Rows.Count

    c = Target.CurrentRegion.Columns.Count

    Cells(Target.Row, "C").Resize(r, c - 2).Sort Key1:=Cells(Target.Row, "C"), Order1:=xlAscending, Header:=xlYes, _

    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

    End Sub

    0 comments No comments
  2. Anonymous
    2015-09-28T19:36:54+00:00

    I think that's got it!  Thanks so much!!!

    0 comments No comments