ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I sort a list automatically? (https://www.excelbanter.com/excel-discussion-misc-queries/11578-how-do-i-sort-list-automatically.html)

Defoes Right Boot

How do I sort a list automatically?
 
I have a range of indeterminate length consisting of 3 columns (name, team,
goals - it's a top-scorer list.)

What I want to do is have Excel automatically sort the full range based on
the Goals column whenever data is added to the list (ie new scorer entered)
or edited (ie existing scorer gets another goal.) to keep the list always in
order of most goals scored.

Anyone got any ideas?


Paul B

Defoes, try this
This assumes that your first row is a header row, and that you put data in
columns A & B and then in C, it will sort by column C when data is put, or
changed, in column C.
Right click on the worksheet tab and view code, paste in the window that
opens



Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 3 Then

Range("A:C").Sort Key1:=Range("C2"), Order1:=xlDescending, _

Header:=xlYes, OrderCustom:=1, MatchCase:=False, _

Orientation:=xlTopToBottom

End If

End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"Defoes Right Boot" wrote in
message ...
I have a range of indeterminate length consisting of 3 columns (name, team,
goals - it's a top-scorer list.)

What I want to do is have Excel automatically sort the full range based on
the Goals column whenever data is added to the list (ie new scorer
entered)
or edited (ie existing scorer gets another goal.) to keep the list always
in
order of most goals scored.

Anyone got any ideas?





All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com