ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Fixing the date format in a macro or VBA (https://www.excelbanter.com/excel-worksheet-functions/241848-fixing-date-format-macro-vba.html)

Geoff B

Fixing the date format in a macro or VBA
 
I have created a macro of which part is to convert an incorrect date format,
dots instead of dashes, that works fine on my PC. (using Ctrl H to find and
replace . with / in the column)
Unfortunately when the macro is run on other machines the date format
becomes Americanised. And as such something like 08/05/09 becomes 05/08/09
which messes up other calculations done within the macro. The other machines
are set up as Australian so I am assuming the macro somehow loses its local
setting control when not being run on the authors machine.
Is there some way that I can lock the date format as Australian or as
dd/mm/yyyy within the macro?
--


Sam Wilson

Fixing the date format in a macro or VBA
 
Hi,

If you had your dates in column A then include this line after your macro
has done find/replace:

columns("A:A").numberformat = "dd/mm/yyyy"


"Geoff B" wrote:

I have created a macro of which part is to convert an incorrect date format,
dots instead of dashes, that works fine on my PC. (using Ctrl H to find and
replace . with / in the column)
Unfortunately when the macro is run on other machines the date format
becomes Americanised. And as such something like 08/05/09 becomes 05/08/09
which messes up other calculations done within the macro. The other machines
are set up as Australian so I am assuming the macro somehow loses its local
setting control when not being run on the authors machine.
Is there some way that I can lock the date format as Australian or as
dd/mm/yyyy within the macro?
--



All times are GMT +1. The time now is 02:59 AM.

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