Auto Sort Rows in two tables on one Sheet to show 'best performing'

Excel_User_10k

Board Regular
Joined
Jun 25, 2022
Messages
100
Office Version
  1. 2021
Platform
  1. Windows
Hello Excel Masters!

I am trying to get the bottom table to Auto-Sort to show those with the most 'Greens' at the top for Advisers. And the same with the top table for the Stores. I have tried filtering them (as you can see in the Screenshot) but it only alters those few instead of the whole Rows. 'Sort' also doesn't work when the Sheet is Protected and it doesn't do it automatically. Tried Custom Filter and that works but it has to be done manually each time and again is not possible when the Sheet is Protected. The bottom table had the option to custom by Cell Value > Ascending Order, but the top table doesn't show this option for some reason?

All of the data here is the result of different formula's, taking the data from another Sheet(s), in case that makes a difference. And I have Row 10 upwards Frozen so that if you scroll down through advisers, the Headers and Store Table stay in place. Again, just in case this matters. (Perhaps you can give me a tip on hiding the line for the Frozen Rows too? At least whilst it is Protected anyway)

(If possible, for the bottom/Adviser table, I would like it to auto hide/filter the Rows that just have "First Name" and "Surname")

And I would like to be able to do all of those on 12 Sheets with the same layout as here but for each Month of the Year.
 

Attachments

  • 1664909377555.png
    1664909377555.png
    235.2 KB · Views: 23
Last edited:

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
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("N:N")) Is Nothing Then
Range("N3").Sort Key1:=Range("N4"), _
Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

I found this VBA code, which works for the top section without affecting the bottom section, which is what I want. But I also want the same to be done for the bottom section. So I thought I could duplicate it and amend it to specify that they both only Sort two different ranges. As shown below:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("N3:N6")) Is Nothing Then
Range("N3").Sort Key1:=Range("N4"), _
Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub
Private Sub Worksheet_Change2(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("N11:N42")) Is Nothing Then
Range("N11").Sort Key1:=Range("N12"), _
Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

Needless to say, this didn't work. Top section still Sorts, but nothing happens when I make any changes to the bottom half. Is something like this possible? Am I on the right track? If there is a way I can just control the Ranges that these codes work then they should be able to work alongside each other, right?
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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