none
How to set Datepicker default value to the last date selected. RRS feed

  • Question

  • I have a form that has a date picker. I want the Datepicker value change to the last date I input.

    1. I set a variable in Datepicker1_change as following:

    Datepicker1_change()

    Date1=Datepicker1.value

    end sub

    Userform_initialized()

    Datepicker1.value=Date1

    End Sub

    The problem is that when I exit from Excel, the default date changes to 1/1/1899

    I can save the Datepicker1 value to a cell in a sheet, but I just don't want to do that as I want to keep the sheet as clean. I wonder if there is anyway that I can modify the default value to the last date the user picked.

    Thank you

    Friday, December 19, 2014 10:09 PM

Answers

  • Hello,

    1. You can store the date string in external files or database, for example, create a text file in the Document folder, write the date string into it. When next time you open the file, read the date string from the text file.

    2. If you want to store the date string in the document itself, it's better to store it in the worksheet. If you don't want to do this, you could also store it in the CustomDocumentProperties.

    ThisWorkbook.CustomDocumentProperties.Add Name:="Date1", LinkToContent:=False, Type:=msoPropertyTypeNumber, Value:=Datepicker1.value


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 22, 2014 7:39 AM
    Moderator

All replies

  • Runtime – you might have more success posting your question in an Excel forum.


    peter n roth - http://PNR1.com, Maybe some useful stuff

    Saturday, December 20, 2014 4:56 PM
  • Hello,

    1. You can store the date string in external files or database, for example, create a text file in the Document folder, write the date string into it. When next time you open the file, read the date string from the text file.

    2. If you want to store the date string in the document itself, it's better to store it in the worksheet. If you don't want to do this, you could also store it in the CustomDocumentProperties.

    ThisWorkbook.CustomDocumentProperties.Add Name:="Date1", LinkToContent:=False, Type:=msoPropertyTypeNumber, Value:=Datepicker1.value


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 22, 2014 7:39 AM
    Moderator