Jump to content

Date format changes to text in CSV file


Recommended Posts

Good morning all from NZ.

I download our bank accounts as a CSV file & then I have a macro that imports the CSV sheet into a XLS workbook & this works fine except that lately the date Col is causing problems.

I format the date to dd/mm as part of the macro but The problem is that for some reason, after about 30 rows, the date changes from number/date format to text.

So instead of 17/09 i will have 17/09/2007 AFTER about 30 rows.

Below is the macro that I use to enter date & format cols.

With basebook
Range("H1").FormulaR1C1 = "SheetName"
Range("b2:B" & Cells(Rows.Count, "B").End(xlUp).Row).NumberFormat = "#,##0.00"
Range("H2:H" & Cells(Rows.Count, "A").End(xlUp).Row).Value = ActiveSheet.Name
Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row).NumberFormat = "DD/MM"
Range("A1:I1").Select
Selection.Font.Bold = True
Selection.AutoFilter
End With

I know it changes to text because the date is all left aligned and if I go into the cell place the cursor at the begining of the date & backspace the format changes to DD/MM & right aligns.

What I need to know is can I build in to the macro code that ensure the date will be read as Date in the format DD/MM and if there is a way what is the code?

TIA

Lionel DownUnda

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...