Opening the most recently downloaded file switches UK date format to US date format

  • I'm getting a problem with excel switching UK date fomat to US date format. The code I have is opening the most recent downloaded file in a folder
    and automatically switching the UK date format to a US date format.


    I'm using an excel 2016 xlsm to open an excel 2007-2013 xls file


    The file in question has a UK date format date already and there is no problem if I open this file manually
    so logic tells me there is something that the code is or isn't doing to prevent
    the format switch from occurring or maybe its something to do with the two different types of excel.


    I've had (along with many others I suspect) the annoying never ending UK/US date format problem
    with excel before and managed to work round it but this code is something I have copied from
    somewhere else and I'm unfamiliar with most of it.


    I've tried using the text to columns trick but it seems to behave differently in code than when used manually which is not something I want to do
    as automation of all the processes is what is needed.


    The code switches the date formats as soon as the file is opened so I'm struggling to see where I can put any code in place to stop this happenning
    If its just a code thing then with my very limited coding ability I am guessing the Dir$ or the wildcard are the culprits.


    This code works fine until I encounter a UK day of 12 or under then it switches them around to US format


    The code switches the date formats as soon as the file is opened so I'm struggling to see how I can put any code in place to stop this happening


  • Managed to find a solution,

    Code
    Set InternalWB = Workbooks.Open(xpath & LatestFile, Local:=True) 'Opens file above.


    The Local = true sets the global Time format to the local time format which Excel would otherwise ignore in certain cases....brilliant!!! Taken me a day and a half to find this out. I think I'm happy, but I may be a little sad that it's taken this long and it was such a simple solution....Life

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!