English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have list of team names in one column and there point total in the next column. I want the list to automatically sort in descending order without having to click on the sort function.

2007-04-02 14:24:29 · 2 answers · asked by David D 1 in Computers & Internet Software

2 answers

I'm a little rusty with my VBA, but I think this will work if you enter a value and press enter. You will need to paste this in the workseet object that you want this to run on. (Click Alt-F11 to enter the Visual Basic editor, then click on the spreadsheet where you want this to run in the Project window, then paste this code in). You will also want to change the variable MyCells below to whatever range of cells you want to sort.
--------------------------------------------------------------------

Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Dim MyCells As Range
Set MyCells = Range("A1:A10")

If Not Intersect(Target, MyCells) Is Nothing Then
MyCells.Sort Key1:=Range("A1"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:= xlSortTextAsNumbers
End If

End Sub

2007-04-03 05:59:32 · answer #1 · answered by Dan A 2 · 0 0

What you could do is record a macro that does a sort when you open the spreadsheet. New data will appear in rows that you keyed it but next time you open the sheet it will sort again.

Hope this helps.
Kind Regards,
QwertyKPH @ Yahoo

2007-04-02 23:02:07 · answer #2 · answered by qwertykph 4 · 1 0

fedest.com, questions and answers