ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing the Date format (https://www.excelbanter.com/excel-programming/351624-changing-date-format.html)

reena[_7_]

Changing the Date format
 

I want to write a macro by which I can change the date format fo
dd/mm/yyyy to mm/dd/yyyy.

How to do this

--
reen
-----------------------------------------------------------------------
reena's Profile: http://www.excelforum.com/member.php...fo&userid=3044
View this thread: http://www.excelforum.com/showthread.php?threadid=50568


Bob Phillips[_6_]

Changing the Date format
 
Why use a macro, why not just set the cell format to that?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"reena" wrote in
message ...

I want to write a macro by which I can change the date format fom
dd/mm/yyyy to mm/dd/yyyy.

How to do this?


--
reena
------------------------------------------------------------------------
reena's Profile:

http://www.excelforum.com/member.php...o&userid=30440
View this thread: http://www.excelforum.com/showthread...hreadid=505689




Tom Ogilvy

Changing the Date format
 
but if you do want to set the format of a cell to mm/dd/yyyy with code, you
would use the numberformat property of the cell

Activecell.Numberformat="mm/dd/yyyy"

This will work if the underlying value in the cell is a date serial number.
If it is a text string, then no amount of formatting will change it. You
will need to parse out the components and rearrange them. Post back if
that is what you want.

--
Regards,
Tom Ogilvy

"reena" wrote in
message ...

I want to write a macro by which I can change the date format fom
dd/mm/yyyy to mm/dd/yyyy.

How to do this?


--
reena
------------------------------------------------------------------------
reena's Profile:

http://www.excelforum.com/member.php...o&userid=30440
View this thread: http://www.excelforum.com/showthread...hreadid=505689





All times are GMT +1. The time now is 12:24 AM.

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