Hi I would like to sort the whole C column based on the values(Critical, high, medium,low). I am running this code on macro enabled worksheet
Here is my code.
<
Your custom sort criteria needs to be in an array. Try,
Sub runSortC()
Dim vCustom_Sort As Variant, rr As Long
vCustom_Sort = Array("Critical","High","Medium","Low", Chr(42))
Application.AddCustomList ListArray:=vCustom_Sort
with Range("C:C")
.parent.Sort.SortFields.Clear
'sort on custom order with header
.Cells.Sort Key1:=.Columns(1), Order1:=xlAscending, _
Orientation:=xlTopToBottom, Header:=xlYes, MatchCase:=False, _
OrderCustom:=Application.CustomListCount + 1
.parent.Sort.SortFields.Clear
End With
End Sub
If this is in a public module, a qualified parent worksheet reference would help.