Consulting

Results 1 to 10 of 10

Thread: Sleeper: Calendar Object Destination Cell Formatting

  1. #1
    VBAX Regular
    Joined
    Aug 2004
    Posts
    12
    Location

    Sleeper: Calendar Object Destination Cell Formatting

    Can anyone explain to me why the formatting of a destination cell for a calendar object won't always work? It seems there are times when I can change the formatting for the specified cell to read as I need it to (i.e. November 18, 2004) but most of the time it will only allow the default (11/18/2004). It's driving me crazy! I've tried adjusting the cell size, deleting any formatting, changing the format in the calendar properties and nothing seems to work. Is this one of those Excel quirks or am I once again missing the obvious?

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi,

    Are these on seperate computers? If so, do both have the Reference to the Calendar Control?

  3. #3
    VBAX Regular
    Joined
    Aug 2004
    Posts
    12
    Location
    Same computer. I had originally had the control in the worksheet with the proper formatting and then deleted it. Upon adding it back, I couldn't get it back to the proper formatting.

  4. #4
    VBAX Newbie
    Joined
    Nov 2004
    Posts
    2
    Location
    Weird! Cruddy control.

    If you explicitly write to a cell (eg on a click event), the problem goes away. Don't use the LinkedCell thingummy is my tip.


    Private Sub Calendar1_Click()
      Dim myDate
      myDate = Calendar1.Value
      Range("A1").Value = myDate
    End Sub


    Lindon

  5. #5
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Adding a bit to lindon's code. You can also format the value in the code as you like:

    Private Sub Calendar1_Click()  
    Range("A1").Value = Format(Calendar1.Value, "mm/dd/yyyy") 
    End Sub

  6. #6
    VBAX Regular
    Joined
    Aug 2004
    Posts
    12
    Location
    That is the format it is using that i don't want. I want the format to be November 18, 2004 but no matter what I do to the code or the cell, I get 11/18/2004.

  7. #7
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this:
    Range("A1").Value = Format(Calendar1.Value, "mmmm dd, yyyy")

  8. #8
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Maybe as an additional, if that doesn't work, you might try Jacob's suggestion after the fact (I'm not too familiar w/ the Calendar Control)..

    [vba]
    Range("A1").Numberformat = "mmmm dd, yyyy"
    [/vba]

  9. #9
    VBAX Regular
    Joined
    Aug 2004
    Posts
    12
    Location
    Neither worked. This baffles me! Even when I try to format the cell the display never varies from the mm/dd/yyyy format - despite the formatting that I choose. I've tried different cells but get the same result. What doesn't make any sense is that it's worked perfectly before.

  10. #10
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Can you post an attachment for us to test?

Posting Permissions

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