excel - Hide rows based on Date input -
i have sheet, data24h
, filled data sorted date.
i want create function user show data specific date.
so created userform
user inputs date in textbox1
, want program hide every row not included in date interval.
the hide-function seems work condition not work. if have today's date yymmdd input still show dates.
i new programing in general , vba in particular , understand if question bit vague , code looks #!!#@.
private sub commandbutton1_click() datum = textbox1.value sheets("data24h").select beginrow = "" endrow = 100 chkcol = 3 rowcnt = beginrow endrow if cells(rowcnt, chkcol).value >= datum cells(rowcnt, chkcol).entirerow.hidden = true else cells(rowcnt, chkcol).entirerow.hidden = false end if next rowcnt columns("a").select unload me Återställ1.show end sub
so tried using autofilter still can't manage. error 1004 in "last" autofilter row. understand error because autofilter believes range empty?
edit: did it! autofilter solved it! missed := in fields. efforts.
private sub commandbutton1_click() dim datum date dim datum_l long sheets("data24h").select datum = cdate(me.textbox1.value) data24h autofiltermode = false selection.range("a2:a100").autofilter selection.range("a2:a100").autofilter field = 1, criteria1:=">=" & datum end
first off add declaration datum variable (dim datum date)
next rewrite line setting date datum = cdate(textbox1.value)
this started. makes comparison between value in textbox , values in cells better (assuming values in cells true dates)
Comments
Post a Comment