+ Reply to Thread
Results 1 to 9 of 9

set datepicker value to current date on workbook open

  1. #1
    Registered User
    Join Date
    11-11-2014
    Location
    Cheltenham, England
    MS-Off Ver
    2010
    Posts
    19

    set datepicker value to current date on workbook open

    As the title really I want to be able to set a datepicker DTPicker21 to todays date when the workbook is opened
    Secondally I would like to be able to set a second datepicker DTPicker22 to todays date plus 1 year

    So basically what do I need to add to the Workbook_Open function?

    As I use the change to a datepicker to hide various columns (Code below) I think the next challenge will then be how to also hide those columns when the dates are set on open.


    'h
    Please Login or Register  to view this content.

    Complete novice thrashing posted examples

    Thanks in advance

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: set datepicker value to current date on workbook open

    In the code window for the userform, try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    11-11-2014
    Location
    Cheltenham, England
    MS-Off Ver
    2010
    Posts
    19

    Re: set datepicker value to current date on workbook open

    I have seen similar code so I thnk this is along the right lines however (complete novice here) I cant locate the userform code window. I guess this is because I have the datepicker controls on the worksheet and not a form?

  4. #4
    Registered User
    Join Date
    11-11-2014
    Location
    Cheltenham, England
    MS-Off Ver
    2010
    Posts
    19

    Re: set datepicker value to current date on workbook open

    I have tried including similar in the workbook_open but with no joy

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: set datepicker value to current date on workbook open

    I can't seem to find an initialize event if the date picker is on the worksheet. There may be a work-around. Click the 'Developer' tab and then in the 'Controls' group click 'Design Mode'. Right click the date picker and click 'View Code'. Paste this macro into the window:
    Please Login or Register  to view this content.
    Return to your sheet and click 'Design Mode' to turn it off. When you click on the date picker, it will automatically display today's date. I'm not sure if this works for you. There may be a better solution.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: set datepicker value to current date on workbook open

    Here is another approach. Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet.
    Please Login or Register  to view this content.
    The date will default to today every time you select the worksheet.

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: set datepicker value to current date on workbook open

    Another approach still that meets your original request:
    Please Login or Register  to view this content.
    Put it in the workbook_open. Change "Sheet1" to suit your needs. Save and close the file. Open the file.

  8. #8
    Registered User
    Join Date
    11-11-2014
    Location
    Cheltenham, England
    MS-Off Ver
    2010
    Posts
    19

    Re: set datepicker value to current date on workbook open

    Resource Trial.xlsm


    Thanks for your responses Mumps1. It feels like the last option should work but it isnt I have attached the file to see if this helps make any sense.

    Cheers

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: set datepicker value to current date on workbook open

    It worked for me. After you inserted the macro, did you save the file, close it and then re-open it?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Open a workbook off my desktop then closing current workbook
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2013, 03:34 PM
  2. Excel Log: VBA to Add Row(s) Upon Workbook Open Last through Current Date
    By jdppep in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2013, 04:22 PM
  3. Open workbook, copy rows, paste to end of current workbook
    By gmn734 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2013, 05:16 AM
  4. [SOLVED] VBA to Open File (filename contains current date) & copy Sheet to active workbook
    By jlstidham in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 10:50 PM
  5. How to open,save and close another workbook from the current workbook using macro?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 10:42 AM

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