Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Setting a default date in a form

  1. #1
    Guest

    Default


    Hi I have a form ready for use that I made on VBA. One of the fields is a date field, and all I want is for it to show as default today's date always

    What is the code for this?

  2. #2
    Board Regular Steve Hartman's Avatar
    Join Date
    Feb 2002
    Location
    Houston,Texas
    Posts
    417
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    =TODAY()

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Just use

    =Date

    Wrap a format around it to display how you want it to appear eg

    =Format(Date, "mmmm dd yyyy")

  4. #4
    Guest

    Default

    This is sort of what I want, it's just that it is a text box and is empty at the moment by default. I want it so tat every time the form loads up, today's date is there as default, showing in the box

  5. #5
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    If it's named TextBox1, just use

    TextBox1.Text = Date
    TextBox1.Locked = True ' So it can't be changed, also can do this via the textbox properties window

    in the form's UserForm_Initialize event (double-click on the form in the VBA editor, ignore the click event sub that comes up and choose the Initialize event from the right-hand drop-down).

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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