+ Reply to Thread
Results 1 to 12 of 12

Date Picker Control will not display Current Date

  1. #1
    Registered User
    Join Date
    02-02-2010
    Location
    Indianapolis, Indiana, USA
    MS-Off Ver
    Office Pro 2007 at Work - Office 2010 Beta at Home
    Posts
    23

    Date Picker Control will not display Current Date

    I am using a couple of Microsoft Date and Time Picker 6.0 (SP4) controls within my Excel workbook. I would like for these controls to automatically fetch the current date. How can I do this?

    Sorry if this is within the wrong subforum.
    Last edited by SP Brian; 03-16-2010 at 05:57 PM.

  2. #2
    Registered User
    Join Date
    02-02-2010
    Location
    Indianapolis, Indiana, USA
    MS-Off Ver
    Office Pro 2007 at Work - Office 2010 Beta at Home
    Posts
    23

    Re: Date Picker Control will not display Current Date

    Any feedback?

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Date Picker Control will not display Current Date

    Where are the controls? On a userform or a worksheet?
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    02-02-2010
    Location
    Indianapolis, Indiana, USA
    MS-Off Ver
    Office Pro 2007 at Work - Office 2010 Beta at Home
    Posts
    23

    Re: Date Picker Control will not display Current Date

    Within a worksheet.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Date Picker Control will not display Current Date

    I thought the default was the current date, try
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    02-02-2010
    Location
    Indianapolis, Indiana, USA
    MS-Off Ver
    Office Pro 2007 at Work - Office 2010 Beta at Home
    Posts
    23

    Re: Date Picker Control will not display Current Date

    Could you break the code down for me, please? Sorry for my ignorance when it comes to code. I know that "sub" means subroutine and that DTPicker1 is the name of the picker and that ".Value" means that I am setting the value of the DTPicker1 to equal "Date". Does "Date" fetch the system date or how does that work?

    Also, what does Private Sub Worksheet_Activate() mean?

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Date Picker Control will not display Current Date

    Date() does indeed return the current system date.
    The Worksheet_Activate event fires whenever you activate the worksheet containing the code.

  8. #8
    Registered User
    Join Date
    02-02-2010
    Location
    Indianapolis, Indiana, USA
    MS-Off Ver
    Office Pro 2007 at Work - Office 2010 Beta at Home
    Posts
    23

    Re: Date Picker Control will not display Current Date

    The code works; however, upon opening the .xlsx file the worksheet opened is the one containing the date picker, so the control is only updated with the current date after I enabled ActiveX/Macros and switch to a different sheet then back to the sheet containing the control.

    Is there a way that I can make this take effect upon the user enabling the ActiveX/Macros?
    Last edited by SP Brian; 03-16-2010 at 05:38 PM.

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Date Picker Control will not display Current Date

    Yes - you need to use the Workbook_OPen event. This code needs to go into the ThisWorkbook module:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    02-02-2010
    Location
    Indianapolis, Indiana, USA
    MS-Off Ver
    Office Pro 2007 at Work - Office 2010 Beta at Home
    Posts
    23

    Re: Date Picker Control will not display Current Date

    Works like a charm. Thank you!

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Date Picker Control will not display Current Date

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  12. #12
    Registered User
    Join Date
    03-04-2011
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Date Picker Control will not display Current Date

    What would the code be for putting the date picker in a userform? thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1