excel - Filter dates before today -
excel - Filter dates before today -
good day,
could help me prepare code found , edited? supposed filter column o , show dates less or before date today. take note cell ac2 shows date today can't play code.
with sheets(1) myval = application.worksheetfunction.workday(sheets(1).range("ac2").value) sheets(1).range("a1:aa1").autofilter field:=15, criteria1:="<=" & myval
if understand correctly, below should trick. filter show dates before current date, whenever code run, according computer's scheme time:
sub datefilter() sheets(1).range("a1:aa1").autofilter field:=15, criteria1:="<" & date end sub
if want today included, alter "<" "<=". "date" vba way refer current date. uses computer's scheme time.
the workday function used find date number of workdays after date. utilize this:
workday(starting date, number of workdays count)
so, if wanted filter column o based on, say, before date 5 workdays after date given in cell ac2, use:
sub datefilter() dim myval date myval = application.worksheetfunction.workday(range("ac2").value, 5) sheets(1).range("a1:aa1").autofilter field:=15, criteria1:="<" & myval end sub
excel excel-vba
Comments
Post a Comment