Hello kscott,
The following macro has been added to the attached workbook. This copy the discharge patient information and then sort it alphabetically when the discharge date is entered.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim DstRng As Range
Dim LastCol As Long
Dim LastRow As Long
Dim NextRow As Long
If Target = "" Or Target.Row = 1 Or Target.Cells.Count > 1 Then Exit Sub
If Target.Column <> Columns("AA").Column Then Exit Sub
Set DstRng = Worksheets("Discharged").UsedRange
Application.EnableEvents = False
With DstRng
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
NextRow = IIf(LastRow < 2, 2, LastRow + 1)
End With
Target.EntireRow.Copy Destination:=DstRng.Cells(NextRow, "A")
Set DstRng = DstRng.Resize(NextRow, LastCol)
DstRng.Sort Key1:=DstRng.Cells(1, 1), Order1:=xlAscending, Header:=xlYes, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Application.EnableEvents = True
End Sub
Bookmarks