I have the below code, what it does it selects the columns (A to N) then till the last non blank sell and then it will sort column D (Contains date) order1:=xlAscending, Header:=xlNo
but giving me an error as "The sort data is not valid, make sure that its within the data you want to sort"
but giving me an error as "The sort data is not valid, make sure that its within the data you want to sort"
Code:
Sub Sot()
ActiveSheet.Range("A1").Select
ActiveSheet.Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select
Selection.sort key1:=Range("D1", Range("D1").End(xlDown)), _
order1:=xlAscending, Header:=xlNo
end sub