VBA code for Automatic sorting of cricket points table.

amruthubballi

New Member
Joined
Apr 27, 2017
Messages
11
Ihave created points table with net run rate calculator. The Table is as follows.
MNOPQRS
4TEAMPLAYEDWINSLOSENO RESULTNET RUN RATEPOINTS
5SRH14950+0.28418
6CSK14950+0.25318
7KKR14860-0.07016
8RR14770-0.25014
9MI14662+0.31714
10RCB14662+0.12914
11KXIP14680-0.50212
12DD14590-0.2228

<tbody>
</tbody>

I want tosort the table automatically when I updated score in other cells (which islinked to points table) i.e whenever worksheet changes.
I want tosort all simultaneously
1) in descending of points (Team havingmore points should be first)
2) in descending of wins (if teamshaving same points then team having most no of wins should be first)
3) in descending of net run rate ( Ifteam has same points and same wins then team having high net run rate should befirst.
I have writtenfollowing code but it has error I m not understanding to fully automate theprocess.

Private SubWorksheet_Change(ByVal Target As Range)
Subsortonmorethan3cols()
Range("M4:S12").CurrentRegion.SortKey1:=Range("S4"), order1:=xlDescending, Header:=xlYes,Key2:=Range("O4"), order2:=xlDescending, Header:=xlYes,Key3:=Range("R4"), order3:=xlDescending, Header:=xlYes

End Sub
End Sub
I REQUEST YOU
TO PLEASE HELP ME TO WRITE THE VBA CODE
I HOPE SOME ONE WILL HELP ME TO RESOLVE THIS....

Thank You
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

rpaulson

Well-known Member
Joined
Oct 4, 2007
Messages
1,170
just this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("M4:S12").Sort Key1:=Range("S4"), order1:=xlDescending, Header:=xlYes, Key2:=Range("O4"), order2:=xlDescending, Header:=xlYes, Key3:=Range("R4"), order3:=xlDescending, Header:=xlYes
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,129,945
Messages
5,639,120
Members
417,073
Latest member
CBG_Christian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top