Hello Everyone,
I would like to create a macro on excel 2013 which sorts the selected cells. But I could not figure out how to set the key as the first column of the selected range. Just give you a clue I altered the recorded macro as below but, as you can guess the part
should be the first column of my selected range.
thanks fort the help in advance
have a great day/night
Cheers
Baha
I would like to create a macro on excel 2013 which sorts the selected cells. But I could not figure out how to set the key as the first column of the selected range. Just give you a clue I altered the recorded macro as below but, as you can guess the part
Code:
Key:= _
Range("B461:B474")
thanks fort the help in advance
have a great day/night
Cheers
Baha
Code:
Sub Sort2()
ActiveWorkbook.Worksheets("ShiftAssignments (2)").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ShiftAssignments (2)").Sort.SortFields.Add Key:= _
Range("B461:B474"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("ShiftAssignments (2)").Sort
.SetRange Selection
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub