Individual sorting with the help of VBA

Super Contributor

Hello Everyone, 

I want to sort individual like DivisionSort, CategorySort and Total Sort.

So, what should i add in VBA code so it will sort individually??

 

Please help ...

 

Here is a attached file..

4 Replies

@Zan_Hanifee 

What do you mean by "sort individually"?

When i choose DivisionSort, then it should sort Division cloumn only
Or
When i choose CategorySort, then it should sort Category cloumn only

@Zan_Hanifee 

But that would break the connection between the data! For example, row 2 now has Division = West, Category = Technical Support and Total = $550. If you sort on Division, the division in row 2 will be East but the category will still be Technical Support and the total will still be 550.

But if you really want to completely mess up your data:

Sub DivisionSort()
    Dim m As Long
    m = Range("A" & Rows.Count).End(xlUp).Row
    Range("A3:A" & m).Sort Key1:=Range("A3"), Header:=xlYes
    MsgBox "Division column sorted", vbInformation
End Sub

Sub CategorySort()
    Dim m As Long
    m = Range("B" & Rows.Count).End(xlUp).Row
    Range("B3:B" & m).Sort Key1:=Range("B3"), Header:=xlYes
    MsgBox "Category column sorted", vbInformation
End Sub

Sub TotalSort()
    Dim m As Long
    m = Range("F" & Rows.Count).End(xlUp).Row
    Range("F3:F" & m).Sort Key1:=Range("F3"), Header:=xlYes
    MsgBox "Total column sorted", vbInformation
End Sub
Thank you so much sir.