Consulting

Results 1 to 4 of 4

Thread: Getting a VBA-Created Date to Format Correctly

  1. #1

    Getting a VBA-Created Date to Format Correctly

    I am using VBA to create a new sheet, then populate it with data. As an afterthought, I decided to add a revision date:

    Range("A1") = Format(Date,"mmm d, yy")
    Well, it writes the date, but the format is 13-Apr-05.
    I know I can go into Excel and format it correctly, but why doesn't the VBA Format function do it for me??

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Well, you are just putting the value in the cell. Regardless of the format you enter it as, it will still be formatted based on the cell's specific formatting.


    Range("A1") = Date
        Range("A1").NumberFormat = "mmm d, yy"

  3. #3
    Thanx, DRJ ... I knew I was missing something.

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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