Using Date picker in Visual Basic with a Userform

  • MODERATOR NOTICE: This topic has also been posted on other sites and may already have an answer elsewhere. Please take this into consideration when answering this question


    What im wanting to do is this (There are 6 Datepickers in the workbook)

    1. I want to be able to when i open a userform in excel i want to have the Date picker to default to the current date.

    2. I want know in the code that im about to post what code i should use to make this happen and where to put it in the macro. This code is in the initialize part of the workbook.

    3. Im going to attach the excel file also.

    4.The Date picker i have used is the one that is in the tool box in the visual basic.

    5. If you cant tell me how to do this with the toolbox please let me know how it can be done with my code that i have by adding more code or how ever.


    Thanks


  • Hello,


    The DatePicker is an additional control in the UserForm ToolBox ... (provided the DLL library is available on your computer)


    see explanation :


    Should you have difficulties, depending on your own system or configuration ...


    see https://www.ablebits.com/offic…xcel-datepicker-template/


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • DatePickers are not available on many systems. I would never use one in any project, especially if it is to be used by others. This would mean checking that the DatePicker is installed on every machine to use it.


    Take a look at my non-ActiveX alternatives.


    Alternative DatePickers

  • Guys my problem is how do i use these calanders in a userform? i dont know how to get them into the form and code it to where it will work.

    Sorry but i need some detail instruction.

    Attached is a very simple (quickly drafted) example : DatePicker in UserForm ... for your inspiration ;)


    Hope this will help

    :)

    Files

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Hello Dennis,


    Attached is your test file


    Modifications were added for your TextBox13 ... you do need to replicate them for all your other 6 identical Text Boxes


    Hope this will help

    :)

    Files

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Wow Carim thank you !

    Couple other thing that i was wondering about:

    1. when i click that text box and the calender pops up can it be set up to where it will default to the current date and show up in the textbox?

    2. can you explain the class modules to me and how they work? i did some research but didnt get much out of the research.


    Thanks

    Dennis

  • Glad to hear you are pleased :)


    But ... your question leads me to believe you have not tested the UserForm ...!!!=O

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Carmin,


    I did test the userform and i want to say thanks for helping me.

    what i thought could possible happen when i opened the userform the date would show up in that textbox instead of haveing to click the textbox and the datepicker show up and me pick the date.

    if it does that i didnt see it doing that and not sure that can happen either.


    Thanks