ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to convert mmddyyyy format into mm/dd/yyyy format (https://www.excelbanter.com/excel-programming/407454-macro-convert-mmddyyyy-format-into-mm-dd-yyyy-format.html)

maijiuli

Macro to convert mmddyyyy format into mm/dd/yyyy format
 
Hello,

I'm trying to write a macro to do this function:

=DATE(RIGHT(e2,4),LEFT(e2,LEN(e2)-6),LEFT(RIGHT(e2,6),2))

I attempted to record the macro and then used an existing loop function off
another part of code to loop through all dates in column E but is not working
too well.

Thank you very much,


--
Thank You!

MikeAllgood

Macro to convert mmddyyyy format into mm/dd/yyyy format
 
Have you tried using the Format command in a macro script? It would look
something like,

dMyDate=Format(dExistingDate, "mm/dd/yyyy").

Note that the dd will always return a two digit date. Single digit dates
will be preceeded by a "0".

Hope that helps.
Mike

"maijiuli" wrote:

Hello,

I'm trying to write a macro to do this function:

=DATE(RIGHT(e2,4),LEFT(e2,LEN(e2)-6),LEFT(RIGHT(e2,6),2))

I attempted to record the macro and then used an existing loop function off
another part of code to loop through all dates in column E but is not working
too well.

Thank you very much,


--
Thank You!


ward376

Macro to convert mmddyyyy format into mm/dd/yyyy format
 
Why not just

Selection.NumberFormat = "mm/dd/yyyy"

Cliff Edwards



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

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