i wanna sort ascending and descending.i have done the if...........then.the problem is when i wanna run the if..........then the error pops up object require,run time error 424.members can help me to check wat's wrong wit it?ty Code: ---------...
i wanna sort ascending and descending.i have done the if...........then.the problem is when i wanna run the if..........then the error pops up object require,run time error 424.members can help me to check wat's wrong wit it?ty
Code:
Sub sort()
Dim sort As Variant
sort = InputBox("To sort the driver code ascending", "sort", "descending")
' sort Macro
'
' Keyboard Shortcut: Ctrl+s
'
If ascending.sort = vbTrue Then
Range("D9

18").Select
ActiveWorkbook.Worksheets("Sheet1").sort.SortField s.Clear
ActiveWorkbook.Worksheets("Sheet1").sort.SortField s.Add Key:=Range("D9"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").sort
.SetRange Range("D9

18")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Else
End If
If descending.sort = vbTrue Then
Range("D9

18").Select
ActiveWorkbook.Worksheets("Sheet1").sort.SortField s.Clear
ActiveWorkbook.Worksheets("Sheet1").sort.SortField s.Add Key:=Range("D9"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").sort
.SetRange Range("D9

18")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End Sub