I have a worksheet with Date values. Excel interprets them correctly as Dates.
I have a VBA function that accepts a Date parameter.
When I call this function from the worksheet, sometimes it works correctly, and sometimes it doesn't. When I set a breakpoint in the function to examine the value passed in to the function from a cell that is incorrect, I discover that the wrong date is passed to the function--it's a day off from what should be passed to the function. The time value is correct.
This occurs in random places on the worksheet. In fact, in one cell that it didn't work correctly in yesterday, it now works correctly today.
The time portion of the value doesn't seem to make a difference. It can be 22:00 hours, 08:00 hours, it's still off by a day.
Does this make any sense to anyone? I am seriously perplexed.
Edit:
I didn't post any code because I don't find it to be a code issue. But here's the function signature:
Function timeToDecimal(time As Date, semanticTimeFormat As String) As Double
Setting a breakpoint on the first line of executable code in the function, I see that time
is, for example, 1/1/1900 1:09:25 PM
, when, on the worksheet it is clearly 1/2/1900 1:09:25 PM
.
The issue isn't the VBA code I've written. The issue is Excel's passing of the data to the function. Is there some quirk I am unfamiliar with in the interface between Excel and VBA?