Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2006

Tip: Looking for answers? Try searching our database.

Code for auto league tables!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gordon - 16 Dec 2006 08:44 GMT
Hi...

I have 3 columns A - C.

In Column A I have values 1 -15 in descending order.
In Column B I have names of tools.
In Column C I have values that are subject to change.

What I need is some code that will look at the values column C and then
shift the tool names in Column B so that it creates a league table. Column A
can remain unchanged. This all needs to be intuitive and automated so that
there is no user control.

Thanks

GC
Ken Johnson - 16 Dec 2006 10:25 GMT
> Hi...
>
[quoted text clipped - 12 lines]
>
> GC

Hi Gordon,

If the tool with the highest Column C value goes to the top of the
league table then you could try...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C2:C16")) Is Nothing Then
   Application.EnableEvents = False
       On Error GoTo ERROR_HANDLER
           Range("B2:C16").Sort Key1:=Range("C2"), _
           Order1:=xlDescending, Header:=xlNo, _
           OrderCustom:=1, MatchCase:=False, _
           Orientation:=xlTopToBottom, _
           DataOption1:=xlSortNormal
   Application.EnableEvents = True
End If
Exit Sub
ERROR_HANDLER: Application.EnableEvents = True
End Sub

If the tool with the lowest Column C value goes to the top of the
league table then you could try...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C2:C16")) Is Nothing Then
   Application.EnableEvents = False
       On Error GoTo ERROR_HANDLER
           Range("B2:C16").Sort Key1:=Range("C2"), _
           Order1:=xlAscending, Header:=xlNo, _
           OrderCustom:=1, MatchCase:=False, _
           Orientation:=xlTopToBottom, _
           DataOption1:=xlSortNormal
   Application.EnableEvents = True
End If
Exit Sub
ERROR_HANDLER: Application.EnableEvents = True
End Sub

Choose the appropriate code, copy it, right click the sheet tab, select
"View Code", paste the code, press Alt + F11 to get back to Excel.

Ken Johnson
Bob Phillips - 16 Dec 2006 10:54 GMT
E2: =INDEX($B$2:$B$16,MATCH(SMALL(C$2:C$16,ROWS($1:1)),$C$2:$C$16,0))

copy down

Signature

---
HTH

Bob

(change the xxxx to gmail if mailing direct)

> Hi...
>
[quoted text clipped - 13 lines]
>
> GC
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.