Dear Joemo, CLng(dte) has solved my frustrating date calculation issues I had in my macro.Code:Sub test() Dim dte As Date dte = #6/18/2018# MsgBox CLng(dte) End Sub
You are welcome - thanks for letting me know!Dear Joemo, CLng(dte) has solved my frustrating date calculation issues I had in my macro.
Thanks a lot.
Code:Sub test() Dim dte As Date dte = #6/18/2018# MsgBox CLng(dte) End Sub
The hash marks (#) indicate to VBA that what the marks enclose is a date (a number not text).Can you clarify on the usage of # before and after the date.
Sub test()
MsgBox CLng(#6/18/2021#)
'next line generates a run time error for type mismatch
MsgBox CLng("6/18/2021")
End Sub
Thank you for the explanation.The hash marks (#) indicate to VBA that what the marks enclose is a date (a number not text).
VBA Code:Sub test() MsgBox CLng(#6/18/2021#) 'next line generates a run time error for type mismatch MsgBox CLng("6/18/2021") End Sub
You are welcome - thanks for the reply.Thank you for the explanation.