can i automaticity sort data in a table

  • Thread starter Thread starter allan
  • Start date Start date
Lets say we are entering data in columns A, B, & C, one row at a time. After
entering the value in column C, we want the data to automatically re-sort by
column A.

Enter the following code in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set c = Range("C:C")
If Intersect(t, c) Is Nothing Then Exit Sub
Application.EnableEvents = False
Columns("A:C").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
t.Offset(1, -2).Select
Application.EnableEvents = True
End Sub


REMEMBER: the worksheet code area, not a standard module.
 
Just be very careful when entering data.

After you enter an incorrectly spelled string or wrong number and the autosort
takes place, it may be difficult to track the error.


Gord Dibben MS Excel MVP
 
In my scenario there are columns A through O where as a case gets added to
the monthly load it goes on the list columns a and b are entered, then it
comes in enter a date into column c then I start the process column D gets a
date, I have a sort indicator set up in a column to sort by 1 through 16, I
want the system to auto sort every time I change the sort indicator from 1
through to 16, based on your model do I change the "C" to the column with the
sort indicator?

Thank you for your help.
 
Back
Top