ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   text to date (https://www.excelbanter.com/excel-programming/354552-text-date.html)

andrew

text to date
 
Hi,
Is there a way that I can convert month and year numbers into dates in
vba analagous to the "=Date()" function in excel. For instance, how
can I convert 12/2005 into a date number in vba without using "=Date"
in a worksheet cell?

Thanks,
Andrew


Norman Jones

text to date
 
Hi Andrew,

Try:

'=============
Public Sub Tester002()
Dim DTE As Date

DTE = DateValue("12/2005")
MsgBox DTE

End Sub
'<<=============


---
Regards,
Norman



"andrew" wrote in message
oups.com...
Hi,
Is there a way that I can convert month and year numbers into dates in
vba analagous to the "=Date()" function in excel. For instance, how
can I convert 12/2005 into a date number in vba without using "=Date"
in a worksheet cell?

Thanks,
Andrew




Niek Otten

text to date
 
Hi Andrew,

use the DateValue function, directly available in VBA

--
Kind regards,

Niek Otten


"andrew" wrote in message
oups.com...
Hi,
Is there a way that I can convert month and year numbers into dates in
vba analagous to the "=Date()" function in excel. For instance, how
can I convert 12/2005 into a date number in vba without using "=Date"
in a worksheet cell?

Thanks,
Andrew




andrew

text to date
 
Thanks! This is great



All times are GMT +1. The time now is 05:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com