Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Newtown, Pennsylvania, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Format a column in code (2000/SP3)

    I want to format column "I" on my spreadsheet in vbShortDate format, but keep getting various error messages. The code should be something like the following (I think):
    With ws
    With .Range("I1")
    .EntireColumn.Format vbShortDate ' - Not correct!!
    End With
    End With

    Would appreciate guidance on what the correct text should be - I do not have my Excel coding text books handy, and the Help file has not helped!

    TIA

    Kiwi44

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date Format a column in code (2000/SP3)

    Recording a macro is a good way to find out.

    .EntireColumn.NumberFormat = "m/d/yyyy"

    Note: although this looks like a specific US date format, it will be translated to whatever has been set as the short date format on the user's system. On my PC, it results in dd-mm-yyyy since that is my short date format.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Newtown, Pennsylvania, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Format a column in code (2000/SP3)

    Many thanks! Works perfectly!

Posting Permissions

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