Maybe like this (untested, and written in Excel 2003, so it doesn't compile)
Public Sub SortValueAscending(rSort As Range, rKey As Range)
With rSort.Parent.Sort
.SortFields.Clear
.SortFields.Add Key:=rKey, _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.SetRange Range("A1").CurrentRegion
.Header = xlGuess ' there's no need to guess; change to xlYes or xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.Apply
End With
End Sub
Private Sub OKButton_Click()
Dim someSortRange As Range
Dim someKeyCell As Range
Set someSortRange = ActiveSheet.UsedRange ' or something else
Set someKeyCell = Range("E1") ' or something else
If UserForm1.OptionButton1.Value And _
UserForm1.OptionButton7.Value Then SortValueAscending someSortRange, someKeyCell
End Sub
Bookmarks