T
terilad
Hi,
I am looking for some help with a code.
I am looking to sort a range of cells in order smallest to largest by a
click of a cell but the code I have written does not work with the click of
the cell can anyone help.
Here is the code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Address = Range("K2").Address Then
If MsgBox("Do you want Put Staff into OT Order", vbYesNo + vbInformation,
"Galashiels Operational Resources © MN ") <> _
vbYes Then Exit Sub
Sub OTOrder()
Range("A716").Select
ActiveWorkbook.Worksheets("Staff OT").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Staff OT").Sort.SortFields.Add
Key:=Range("C7:C16" _
), SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Staff OT").Sort
.SetRange Range("A716")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
End Sub
Many thanks.
Mark
I am looking for some help with a code.
I am looking to sort a range of cells in order smallest to largest by a
click of a cell but the code I have written does not work with the click of
the cell can anyone help.
Here is the code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Address = Range("K2").Address Then
If MsgBox("Do you want Put Staff into OT Order", vbYesNo + vbInformation,
"Galashiels Operational Resources © MN ") <> _
vbYes Then Exit Sub
Sub OTOrder()
Range("A716").Select
ActiveWorkbook.Worksheets("Staff OT").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Staff OT").Sort.SortFields.Add
Key:=Range("C7:C16" _
), SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Staff OT").Sort
.SetRange Range("A716")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
End Sub
Many thanks.
Mark