Enter the statement Option Explicit at the top of your macro. Then VBA will show your "misstake".
The only variable comparison that we might expect to work is:
It fails because openDate and closeDate are empty -- because they are misspelled.
The correct variable names are dateOpen and dateClose
-----
FYI, the other "variable" comparisons fail because expressions of the form " & tDate & " are strings.
Not only are the "variables" tDate etc __not__ substituted in the strings, but also "&" and "#" are simply characters, not the "operators" that you intended.
PS.... After correcting the variable spellings, "try 3" __seems__ to work. But it is doing a __string__ comparison, not a date comparison. It will not work as intended with certain well-chosen dates.
Bookmarks