Convert date toregional setting on Laptop/PC

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
When I import CSV files into Excel the date format changes from dd/mm/yyyy to mm/dd/yyyy


I have tried to amend my macro for importing files toimport the dates format the same as my regional settings on my Laptop/PC


It seems to do these for the majority of the dates but some dates , but not for all


It would be appreciated if someone could kindly assist me


Code:
 Sub Open_Workbook()
ChDir ("C:\Run Number Reports")
A:
Dim A     As Variant
Dim LR As Long
With Sheets("Data Import")
.UsedRange.ClearContents
End With
ChDir ("C:\Run Number Reports")
     A = Application.GetOpenFilename(MultiSelect:=True)
    If TypeName(A) = "Boolean" Then Exit Sub
    
    Dim file As Variant
    
    Application.ScreenUpdating = False
   For Each file In A
        With Workbooks.Open(file, Local:=True)
        

     
        With Sheets(1)
            .Range("a1", .Range("J" & Rows.Count).End(xlUp)).Copy _
                Destination:=ThisWorkbook.Sheets("Data Import").Range("A" & Rows.Count).End(xlUp).Offset(1)
        
         
        End With
  
        .Close SaveChanges:=False
    End With
 Next
 Application.ScreenUpdating = True
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Rather than using the Workbooks.Open method, try the Worksheet.QueryTables.Add method. That will give you full control over the formats used for the columns. You can use the Macro Recorder to get some sample code by opening one of the files with the From Text wizard on the Data ribbon.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top