I'm attempting to create a macro that will allow a user to set the sort range, field sort parameters, and then perform the sort. I'm able to have the macro bring up an excel input box (I copied an example from a John Walkenbach book) and have the user select the sort range but after that I'm lost. I DON'T KNOW VBA as the example below embarrassingly shows and any help would be greatly appreciated. Here is what the non-functioning code currently looks like:
Sub SortCash()
'
' SortCash Macro
' Sort Cash Rows
'
' Keyboard Shortcut: Ctrl+s
'
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key:=ActiveCell.Offset(0, 0), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveSheet.Sort.SortFields.Add Key:=ActiveCell.Offset(0 _
, 3), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveSheet.Sort.SortFields.Add Key:=ActiveCell.Offset(0 _
, 1), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveSheet.Sort
Dim UserRange As Range
DefaultRange = Selection.Address
Set UserRange = Application.InputBox _
(Prompt:="Select Cells to Sort:", _
Title:="Range to Sort", _
Default:=DefaultRange, _
Type:=8)
UserRange.Select
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub SortCash()
'
' SortCash Macro
' Sort Cash Rows
'
' Keyboard Shortcut: Ctrl+s
'
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key:=ActiveCell.Offset(0, 0), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveSheet.Sort.SortFields.Add Key:=ActiveCell.Offset(0 _
, 3), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveSheet.Sort.SortFields.Add Key:=ActiveCell.Offset(0 _
, 1), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveSheet.Sort
Dim UserRange As Range
DefaultRange = Selection.Address
Set UserRange = Application.InputBox _
(Prompt:="Select Cells to Sort:", _
Title:="Range to Sort", _
Default:=DefaultRange, _
Type:=8)
UserRange.Select
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub