Results 1 to 19 of 19

Thread: Converting Column To Specific Date Format

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    403
    Location

    Converting Column To Specific Date Format

    I'm hoping that somebody can please help me to fathom this one out.

    I have a column of data that has been captured from a bespoke database programme which on the face of it, looks to be in dd/mm/yyyy time format. Having tried to manually select the column and then convert it to the required dd/mm/yyyy format (basically removing the time element), I soon realised that something was not quite right as after applying the required date format, it seemed on the face of it to do absolutely nothing.

    Having then Googled the issue, I believe that the column has been exported and saved in text format and hence why it would not convert to the required date format.

    Ultimately I am trying to get this to function as a macro which will be part of a larger project. Using the macro recorder, I arrived at the following code which although a bit rough and ready, was hoping would provide me with a column 'D' in the required dd/mm/yyyy format, but it only appears to be working on some of the cells and not others.

     Columns("D:D").Select
        Selection.TextToColumns Destination:=Range("D1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(1, 1), TrailingMinusNumbers:=True
        Selection.NumberFormat = "dd/mm/yyyy"
    I'd really appreciate help in getting a bit of macro code to achieve my goal.

    Thanks!
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •