Hello,
I found this VBA that auto sorts a Multiple Column Groups Separately.
____________________________________________
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Range("A5:B50").Sort _
Key1:=Range("A5"), Order1:=xlAscending, _
Key2:=Range("B5"), Order2:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
ElseIf Target.Column = 3 Then
Range("C5:D50").Sort _
Key1:=Range("C5"), Order1:=xlAscending, _
Key2:=Range("D5"), Order2:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub
__________________________________________
But I need to auto sort two separate ranges within the same column like in the image below.
<tbody>
</tbody>
Need to be able to auto sort another table located below
<tbody>
</tbody>
Please help with VBA code.
Thank you!
I found this VBA that auto sorts a Multiple Column Groups Separately.
____________________________________________
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Range("A5:B50").Sort _
Key1:=Range("A5"), Order1:=xlAscending, _
Key2:=Range("B5"), Order2:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
ElseIf Target.Column = 3 Then
Range("C5:D50").Sort _
Key1:=Range("C5"), Order1:=xlAscending, _
Key2:=Range("D5"), Order2:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub
__________________________________________
But I need to auto sort two separate ranges within the same column like in the image below.
1 | Cell A | Cell B | Cell C |
2 | Product | Order Status | Expiration Date |
3 | Carrot | Pending | |
4 | Orange | Pending | |
5 | Pepper | Complete | 2018/12/20 |
<tbody>
</tbody>
Need to be able to auto sort another table located below
Cell A | Cell B | Cell C | |
6 | Product | Order Status | Expiration Date |
7 | Apple | Pending | |
8 | Pear | Complete | 2018/10/15 |
9 | Onion | Complete | 2018/12/25 |
<tbody>
</tbody>
Please help with VBA code.
Thank you!