Text Dates with 2 Digit Year

G

Guest

Data I copy from someone else's worksheets as part of a macro routine I've
developed include many cells containing text dates with 2 digit years. Excel
flags these cells, and allows me to fix the "errors"... Ijust select the
"Convert XX to 20XX" option and all is fine.

Does someone know I way I can perform this conversion from within a macro?

For now I've split my macro into two... I let the 1st macro stop with all
the affected cells selected at which time I manually do all the conversions
as above, and then start a 2nd macro... but that's definitely less than
desireable...

Thanks in advance !!
 
S

stevebriz

Fogcity said:
Data I copy from someone else's worksheets as part of a macro routine I've
developed include many cells containing text dates with 2 digit years. Excel
flags these cells, and allows me to fix the "errors"... Ijust select the
"Convert XX to 20XX" option and all is fine.

Does someone know I way I can perform this conversion from within a macro?

For now I've split my macro into two... I let the 1st macro stop with all
the affected cells selected at which time I manually do all the conversions
as above, and then start a 2nd macro... but that's definitely less than
desireable...

Thanks in advance !!
what is the current format of the date mm/dd/yy or mmddyy or mm-dd-yy
or something else?
 
S

stevebriz

try this
i used B27 as my test cell

Dim strDate As String
Dim formdate As Date
formdate = Range("B27").Value
strDate = Format(formdate, "dd -mmm-yyyy")
MsgBox strDate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top