I have recorded a macro which sorts my list by the dates in ascending order after i filter out the records i want. Is it possible to show only the recent 2 weeks entries and hide the rest?
Sort Datas by Last 2 weeks dates
-
-
-
Re: Sort Datas by Last 2 weeks dates
Can you post your code?
-
Re: Sort Datas by Last 2 weeks dates
Here's the Code:
'Filtering Part Name Through ComboBox1'
Code
Display MorePrivate Sub filterp_Click() Dim Class As String Class = ComboBox1.Value ActiveSheet.Range("A1:AK65000").AutoFilter Field:=1, Criteria1:=Class Columns("I:I").Select Selection.Sort Key1:=Range("I2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End Sub
-
Re: Sort Datas by Last 2 weeks dates
rach85, please use the code tags, as requested, when posting code. [ga]*[/ga] before posting anything further.
-
Re: Sort Datas by Last 2 weeks dates
Please confirm - are you only sorting column I and you don't care about the data in the other cells?
-
-
Re: Sort Datas by Last 2 weeks dates
well.. the code does care about the other columns. The rest of the columns are also sorted along with the column "I". It's just that the sorting criteria is at the column I.
-
Re: Sort Datas by Last 2 weeks dates
rach85, please acknowledge that you have read [ga]*[/ga]
-
Re: Sort Datas by Last 2 weeks dates
yeapz..i have read that and understand abt the code tag as well as doing a search beforehand.
-
Re: Sort Datas by Last 2 weeks dates
Thanks.
-
Re: Sort Datas by Last 2 weeks dates
Try this and let me know if it works for you.
Code
Display MoreDim Class As String Dim FilterRange As Range Class = ComboBox1.Value Set FilterRange = ActiveSheet.Range("A1:AK" & _ ActiveSheet.Range("A65536").End(xlUp).Row) FilterRange.AutoFilter field:=1, Criteria1:=Class FilterRange.Sort Key1:=Range("I2"), Order1:=xlAscending, Header:=xlYes, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom FilterRange.AutoFilter field:=1 FilterRange.AutoFilter field:=9, Criteria1:=">=" & Format(Date - 14, "mm/dd/yyyy"), _ Operator:=xlAnd
Regards,
-
-
Re: Sort Datas by Last 2 weeks dates
thanks Barrie! works great =)
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!