View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Converting dates

Hi Robert,

Am Fri, 10 May 2019 03:12:00 -0700 (PDT) schrieb RG III:

Does VBA have any functions that convert date strings such as M/D/YY, MM/D/YY, or M/DD/YY to MM/DD/YY format?

For example, if sDate == "1/9/19", then the output should be sDate = "01/09/19"


if your date is a string then try for A1:

With Range("A1")
.Value = CDate(sdate)
.NumberFormat = "mm/dd/yy"
End With


Regards
Claus B.
--
Windows10
Office 2016