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.
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.
Any feedback?
Where are the controls? On a userform or a worksheet?
Remember what the dormouse said
Feed your head
Within a worksheet.
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
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?
Date() does indeed return the current system date.
The Worksheet_Activate event fires whenever you activate the worksheet containing the code.
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.
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.
Works like a charm. Thank you!
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
What would the code be for putting the date picker in a userform? thanks!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks