0
votes

I am very new to macros, so I need help with this. I want to sort the excel sheet by a selected column. For example if I have three columns "column1, column2 and column3", I want to be able to select one of the three columns to sort the entire sheet

1

1 Answers

0
votes

Here is a simple example for a descending sort with a Header cell:

Sub SortsRUs()
    Set r = Application.InputBox("Click on a cell in the sort column", Type:=8).EntireColumn(1)
    ActiveSheet.UsedRange.Sort Key1:=r, Order1:=xlDescending, Header:=xlNo, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
End Sub