Auto Sort range by column value change

ngen33r

New Member
Joined
Dec 4, 2018
Messages
4
I have a sheet that I want to auto sort the cell range A13-T33 by column M descending when a cell in column M is updated.



I have tried:

File-Copy-icon.png

<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Private Sub Worksheet_Change(ByVal Target As Range)

On Error Resume Next

If Not Intersect(Target, Range("M:M")) Is Nothing Then

Range("M13").Sort Key1:=Range("M33"), _

Order1:=xlAscending, Header:=xlYes, _

OrderCustom:=1, MatchCase:=False, _

Orientation:=xlTopToBottom

End If

'End Sub</code>

I cannot get it to work.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Cross posted https://www.excelforum.com/excel-pr...9-auto-sort-range-by-column-value-change.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Not Intersect(Target, Range("M:M")) Is Nothing Then
      Range("A13:T33").Sort Key1:=Range("M13"), _
         Order1:=xlAscending, Header:=xlYes, _
         OrderCustom:=1, MatchCase:=False, _
         Orientation:=xlTopToBottom
   End If
End Sub
 
Upvote 0
Sorry for the cross post, I wanted to find the most active forum to use regularly. The function does work but it will not update if the values in column M are calculated. I have cell M = J*K*L. Also can I change ascending to descending.
 
Upvote 0
How about
Code:
Private Sub Worksheet_Calculate()
Range("A13:T33").Sort Key1:=Range("M13"), _
   Order1:=xlDescending, Header:=xlYes, _
   OrderCustom:=1, MatchCase:=False, _
   Orientation:=xlTopToBottom

End Sub
 
Last edited:
Upvote 0
This does update and arrange but after the update some kind of loop is running and laggs the sheet for about 30 iterations of something. The bottom left keeps blinking ready.
 
Upvote 0
Is this any better
Code:
Private Sub Worksheet_Calculate()
Application.Calculation = xlCalculationManual
Range("A13:T33").Sort Key1:=Range("M13"), _
   Order1:=xlDescending, Header:=xlYes, _
   OrderCustom:=1, MatchCase:=False, _
   Orientation:=xlTopToBottom
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0
Are columns J,K & L formulae or hard values?
 
Upvote 0

Forum statistics

Threads
1,215,560
Messages
6,125,523
Members
449,236
Latest member
Afua

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
Back
Top