I cannot seem to get this to work. I have tried multple combinations, but keep getting the 1004 error. Help Please.
Sub RunSort(ColFirst, ColLast, RowFirst, RowLast)
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(RowFirst, ColFirst), Cells(RowLast, ColLast)).Select
ActiveSheet.Sort.SortFields.Clear
Range(Cells(RowFirst, ColFirst), Cells(RowLast, ColLast)).Sort Key1:=Range(Cells(RowFirst, ColFirst)), Order1:=xlAscending, _
Key2:=Range(Cells(RowFirst, ColFirst + 1)), Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
Ignore the "LAstrow", something else I was trying.
Sub RunSort(ColFirst, ColLast, RowFirst, RowLast)
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(RowFirst, ColFirst), Cells(RowLast, ColLast)).Select
ActiveSheet.Sort.SortFields.Clear
Range(Cells(RowFirst, ColFirst), Cells(RowLast, ColLast)).Sort Key1:=Range(Cells(RowFirst, ColFirst)), Order1:=xlAscending, _
Key2:=Range(Cells(RowFirst, ColFirst + 1)), Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
Ignore the "LAstrow", something else I was trying.
Last edited: