ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to create a date conversion in MS Excel using VBA (https://www.excelbanter.com/excel-programming/360854-how-create-date-conversion-ms-excel-using-vba.html)

Sandspirit

How to create a date conversion in MS Excel using VBA
 
Hi,

I have a file that is imported from Attachmate Extra!. The dates appear
in Excel as i.e. 106/04/14, which represents April 14, 2006. How can I
convert all these dates to the standard 04/14/2006 format using VBA? I
have NEVER seen a date format like the one from Attachmate. Please
help.

Thanks!

Sandspirit


[email protected]

How to create a date conversion in MS Excel using VBA
 
As an example
dim n as string
n=range("B1").value
Range("b1").Value = DateSerial(Left(n, 3) + 1900, Mid(n, 5, 2),
Right(n, 2))


would put the value from B1 into a proper date format - you can
obviously extend this to work across all cells in a range


Tim Williams

How to create a date conversion in MS Excel using VBA
 
Function GetDate(v)
GetDate=right(v,5) & "/20" & mid(v,2,2)
end function

--
Tim Williams
Palo Alto, CA


"Sandspirit" wrote in message ps.com...
Hi,

I have a file that is imported from Attachmate Extra!. The dates appear
in Excel as i.e. 106/04/14, which represents April 14, 2006. How can I
convert all these dates to the standard 04/14/2006 format using VBA? I
have NEVER seen a date format like the one from Attachmate. Please
help.

Thanks!

Sandspirit





All times are GMT +1. The time now is 01:25 PM.

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