Grant A
New Member
Hi All,
I have working teams that record data with date and time stamps and am after some assistance with the filtering of this data.
I have two questions which there is attached file for sample data
Question 1 - On sheet 1 enter start date in cell "F5" and finish dates in cell "F7"
this will filter sheet 2 in column C between the dates.
i have the following code but this is only working if the start - finish cells are on same worksheet. I wish to have the date filters on other sheet
PublicSub MyFilter()
Dim lngStart AsLong, lngEnd AsLong
lngStart = Range("B3").Value 'assume this is the start date
lngEnd = Range("C3").Value 'assume this is the end date
'assume you have field name / label in C1
Range("C2:C300").AutoFilter field:=1, _
Criteria1:=">=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="<=" & lngEnd
EndSub
Question 2 - from same date data on sheet 2 column C date and time, am after a code to filter the previous shift events. Our business functions 24 hours with events recorded with time and date stamps. Would request assistance to have filter with starting from now() minus 12 hours to filter down the events in the previous shift.
Regards
GrantA
__________________________________________________________________
I have working teams that record data with date and time stamps and am after some assistance with the filtering of this data.
I have two questions which there is attached file for sample data
Question 1 - On sheet 1 enter start date in cell "F5" and finish dates in cell "F7"
this will filter sheet 2 in column C between the dates.
i have the following code but this is only working if the start - finish cells are on same worksheet. I wish to have the date filters on other sheet
PublicSub MyFilter()
Dim lngStart AsLong, lngEnd AsLong
lngStart = Range("B3").Value 'assume this is the start date
lngEnd = Range("C3").Value 'assume this is the end date
'assume you have field name / label in C1
Range("C2:C300").AutoFilter field:=1, _
Criteria1:=">=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="<=" & lngEnd
EndSub
Question 2 - from same date data on sheet 2 column C date and time, am after a code to filter the previous shift events. Our business functions 24 hours with events recorded with time and date stamps. Would request assistance to have filter with starting from now() minus 12 hours to filter down the events in the previous shift.
Regards
GrantA
__________________________________________________________________
Mod edit : thread moved to appropriate forum !