To avoid confusing Excel, VBA and yourself, only use string date as inputs
(with a 3 or 4 digit year, not 2) and use VBA's date function and Date data
type.
<From Help Date Data Type
Date variables are stored as IEEE 64-bit (8-byte) floating-point numbers
that represent dates ranging from 1 January 100 to 31 December 9999....etc
</From Help
Depending how far back you are going, there that whole business of change in
calenders, missed/extra leap year etc, that it seems anything more than
about 150 years ago is somewhat guesswork.
NickHK
"embirath" wrote in
message ...
Well, I made some changes, and got it to work. But I'm a bit confused
about how this works still.
It looks like when I pass a Date from a worksheet to the VBA function,
I don't need to do the conversion (ie the addition of 1462 days). But,
if I create a date inside the VBA function, and then pass it to the
worksheet, I DO see the 4yr-1day discrepancy, and I do need to subtract
the 1462 days.
Do you understand why it works one way but not the other? How do I know
when I need to do a conversion, and when not (except for just checking
the answers to see what works..?)
I have uploaded a couple of simplified functions that just illustrate
what I'm confused about, without all the other stuff. The first
function needs no conversion, the second one does.
Thanks again for your input.
Emma
+-------------------------------------------------------------------+
|Filename: Module2.bas.txt |
|Download: http://www.excelforum.com/attachment.php?postid=5182 |
+-------------------------------------------------------------------+
--
embirath
------------------------------------------------------------------------
embirath's Profile:
http://www.excelforum.com/member.php...o&userid=37202
View this thread: http://www.excelforum.com/showthread...hreadid=570926