TheGreenApple
New Member
- Joined
- Jun 24, 2018
- Messages
- 3
Hi there,
I want to sort values in descending order of their amount of occurrences in multiple tables say 123 occurs 5 times and 120 occures 3 times, then I need 123 to be listed ahead of 120 along with the times they occur. With vlookup I get the amount of occurrences and with the following code this has worked just fine:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Application.EnableEvents = False
Columns("A:B").Sort Key1:=Range("A1"), Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.EnableEvents = True
End If
End Sub
However, I need to repeat this for Columns D:E; G:H etc. (7 times in total) as I have 7 sets of date which must not be mixed. This is where I'm struggling. How can I do this multiple times independent from one another in the same worksheet please?
Cheers
I want to sort values in descending order of their amount of occurrences in multiple tables say 123 occurs 5 times and 120 occures 3 times, then I need 123 to be listed ahead of 120 along with the times they occur. With vlookup I get the amount of occurrences and with the following code this has worked just fine:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Application.EnableEvents = False
Columns("A:B").Sort Key1:=Range("A1"), Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Application.EnableEvents = True
End If
End Sub
However, I need to repeat this for Columns D:E; G:H etc. (7 times in total) as I have 7 sets of date which must not be mixed. This is where I'm struggling. How can I do this multiple times independent from one another in the same worksheet please?
Cheers