Hi All,
I am trying to write some code that runs through a column in excel and checks if the date within each row in that column falls between two dates that are entered by the user as start date and end date. Unfortunately, it is not working!!
Here is the code:
Could someone please help me. It seems straightforward but somehow it doesnt quite work. PROBLEM EXAMPLE:
If DStartdate = 08/30/2012 and DEndDate = 08/31/2012 then it seems to only count all records where date aka ActiveSheet.Range("H" & i) = 08/30/2012 but it ignores all dates that = 08/31/2012.
I'm down to my last few hairs!! Please help.
THANKS!!!
I am trying to write some code that runs through a column in excel and checks if the date within each row in that column falls between two dates that are entered by the user as start date and end date. Unfortunately, it is not working!!
Here is the code:
Code:
For i = 3 To numrows
If (ActiveSheet.Range("H" & i) >= DStartDate) And (ActiveSheet.Range("H" & i) <= DEndDate) Then
totNumFound = totNumFound + 1
End If
Next
Could someone please help me. It seems straightforward but somehow it doesnt quite work. PROBLEM EXAMPLE:
If DStartdate = 08/30/2012 and DEndDate = 08/31/2012 then it seems to only count all records where date aka ActiveSheet.Range("H" & i) = 08/30/2012 but it ignores all dates that = 08/31/2012.
Totnumfound is being displayed on the sheet but is used in multiple loops through multiple arrays to generate multiple reports on a number of sheets. I'm adding this If statement to evaluate on date so that I can run the report for a particular date period instead of a 'snapshot' showing all records.
The If statement does not fail but does not evaluate properly. The >= and <= should resolve to "between dateA and dateB" but for some reason excludes the records <= dateB.
I just need someone to help me figure out why this is happening or alternatively correct the statement to work properly.
The If statement does not fail but does not evaluate properly. The >= and <= should resolve to "between dateA and dateB" but for some reason excludes the records <= dateB.
I just need someone to help me figure out why this is happening or alternatively correct the statement to work properly.
PLEASE HELP!
I'm down to my last few hairs!! Please help.
THANKS!!!