+ Reply to Thread
Results 1 to 21 of 21

Problem with a Excel Calendar Datepicker in a Floating VBA Userform

Hybrid View

butterscotch Problem with a Excel Calendar... 03-03-2015, 10:58 AM
skywriter Re: Problem with a Excel... 03-03-2015, 03:26 PM
butterscotch Re: Problem with a Excel... 03-03-2015, 03:55 PM
butterscotch Re: Problem with a Excel... 03-04-2015, 05:49 AM
skywriter Re: Problem with a Excel... 03-04-2015, 11:51 AM
skywriter Re: Problem with a Excel... 03-03-2015, 05:10 PM
butterscotch Re: Problem with a Excel... 03-03-2015, 05:30 PM
skywriter Re: Problem with a Excel... 03-03-2015, 05:44 PM
butterscotch Re: Problem with a Excel... 03-05-2015, 05:42 AM
butterscotch Re: Problem with a Excel... 03-03-2015, 06:03 PM
skywriter Re: Problem with a Excel... 03-03-2015, 06:11 PM
butterscotch Re: Problem with a Excel... 03-03-2015, 06:24 PM
skywriter Re: Problem with a Excel... 03-03-2015, 06:37 PM
butterscotch Re: Problem with a Excel... 03-03-2015, 06:54 PM
skywriter Re: Problem with a Excel... 03-03-2015, 07:08 PM
butterscotch Re: Problem with a Excel... 03-03-2015, 07:20 PM
skywriter Re: Problem with a Excel... 03-03-2015, 07:28 PM
mc84excel Re: Problem with a Excel... 03-03-2015, 07:09 PM
MarvinP Re: Problem with a Excel... 03-04-2015, 12:44 PM
  1. #1
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Windows 8.1 64-bit
    Excel 2013 32-bit

    I created the above using the following instructions:-

    https://www.youtube.com/watch?v=EDZjSqukMIM

    I am now experiencing a small problem with the pop-up calendar.

    When I open it, it does not go to the current date/month and, for some reason, it has a specific date greyed out (I am assuming this is because that is the date I created the calendar)

    Photo attached.

    T
    Attached Images Attached Images

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Without the worksheet we can't see the code you are using, nor can we see what properties you have set.

  3. #3
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks skywriter

    I put the calendar in my "Personal" workbook, so that it would be available in all new workbooks. I assume therefore that there is no point of sending it to you.

    I attach the code as I entered it (from the instructional Youtube video mentioned earlier)

    Please let me know if you need anything else.

    I'm not a coder, so I will send what you need, if you send me instructions.

    The calendar opens fine but there are 2 issues:-

    1) It does not go to current date
    2) For some reason, 25/02/2015 is highlighted in grey.

    T
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks skywriter. Your direction has led me to the conclusion that it was, indeed, a duplicate that was causing the problem.

    Following your advice, I backed up both and in the end, decided to delete both and start again from scratch.

    So, here is where I am at the present. I now have a "clean" created calendar.

    The current date is selected, so it appears as if we have resolved that issue. I would like to wait until tomorrow though, to confirm if current date is again selected.

    Perhaps, in the meantime, we could spend some time trying to resolve the second issue. I believe I now understand why the date was highlighted in grey. Please see attached as an explanation of what I did and what the result was.

    T
    Attached Files Attached Files

  5. #5
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Hi T,

    No I doubt that it's a bug, this is just what you get. You should keep experimenting with those properties and see what they do. As far as waiting until tomorrow to see if the date issue is fixed you don't have to do that, you can check it today.

    Date is a function and what that means is it is returning a number to the calendar, hopefully the number is always today's date. The way you can check it is to simply add or subtract a number from it and see if it changes the date. So if you simply type + 1 after the word date and re initialize the form it should be on tomorrow's date and then you can remove the +1.

    This would also be how you could set the calendar to always have a default date of 1 month from today +30. You might be using it for writing invoices and you want it to always be on or close to the day you are going to enter for your invoice and you don't want to have to change it to the next month.

    Thanks for the rep points.
    Good Luck!!!
    Bruce
    Last edited by skywriter; 03-04-2015 at 11:56 AM.

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Click on the calender to select it, then go to the view menu and then properties. Look for the name of the calendar. You should probably just select the name and copy it. Go to the code for the form and in the drop down list at the top on the right choose initialize.
    You should get some code that looks like what's below without the date time picker stuff in it. Add your name then type the period and you should get intellisense giving you some choices, choose value and then type = date. You are recreating what you see below, but you have to use the actual name of your calendar.

    Edit: Okay I didn't scroll down far enough in your PDF. It looks like your calendar is named calendar.
    So if your type Calendar. you should get the intellisense list to pick value from. If you immediately get the list after typing the period we are on the right track. Also type date with a small d and after you hit enter it should turn to a capital D another sign things are working right.

    Private Sub UserForm_Initialize()
    
    DTPicker1.Value = Date
    
    End Sub
    Last edited by skywriter; 03-03-2015 at 05:13 PM.

  7. #7
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks Skywriter

    OK - this is where my lack of coding is a problem.

    Referring back to my attached document, I go to Forms, right-click on Calendar and select "View Code"

    I get a window with a heading PERSONAL.XLSB - Calendar (Code)

    This is what I see:-

    Private Sub CommandButton1_Click()

    Unload Me

    End Sub

    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)

    ActiveCell.Value = DateClicked

    End Sub


    Can you please take it from there?

    Thanks,
    T

  8. #8
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    You know I'm looking at your PDF and I just noticed something. If you changed the name of your userform to Calendar and you named the Calendar calendar, you really don't want to do that. It causes confusion.
    You put the calendar onto a user form correct?
    Click onto the userform, not the calendar, not any buttons, just onto a blank part of the userform and right click and then choose view code. Select initialize from the drop down box as noted below.
    If you like the calendar name, you should name the form something like frmCalendar and the calendar itself something like calCalendar or ctrlCalendar that way it's obvious what object you are talking about. Naming the form and the actual calendar on the form with the name Calendar is not a good idea.


    In your PDF on the left side the second code box down says
    PERSONAL.XLSB - UserForm1(Code)
    Then below it there's a drop down list on the left that says
    UserForm and on the right there's a box that says click.
    When the left one says userform you choose the right one and there's a choice of Initialize. Choose that one and the first and last lines of code that I showed you will automatically be entered into the window. You type the middle line as discussed in my post #4. Save everything and you should be good to go.
    Last edited by skywriter; 03-03-2015 at 05:57 PM.

  9. #9
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks MarvinP

    skywriter

    The current date is being selected correctly now.

    Date of creation is still being highlighted in grey, but I assume that's a bug and something I can live with. Appreciate your support.

    Tommy

  10. #10
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks skywriter.

    OK - that did not work. If I can give further clarification.

    Here is the code now:-

    Private Sub MonthView1_DateClick(ByVal DateClicked As Date)

    End Sub
    ________________________________________________________________________________

    Private Sub UserForm_Click()

    End Sub
    ________________________________________________________________________________

    Private Sub UserForm_Initialize()

    Calendar.Value = Date

    End Sub

    There are 3 parts with the description (in the top-left box) when I click into it.

    The first one says MonthView1, whereas 2 and 3 say UserForm

    T

  11. #11
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Read my post #6, it's really hard to do this if I can't see the actual workbook. I'm looking at your PDF that you sent. Look at the PDF. At the top on the left you have a box that says Calendar(UserForm) next to it is one that says UserForm1(UserForm). Down at the very bottom you have two property boxes that both say Calendar UserForm, now look at my post #6. I'm trying to figure out what you did. If you have a userform and you named it calendar and you have a calendar named calendar, this is not a good idea. Normally I just leave my userform named userform1 whatever it happens to be. Nobody sees this it's just a name, but with code you name multiple things calendar and then try to refer to them in code it gets confusing. So since you won't share the actual calendar with me I'm trying to figure out what you did by your pictures.

  12. #12
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Sorry if I'm confusing things skywriter. I'd be happy to send the workbook, but I thought that as it is a "Personal" workbook where this is saved, then it is unique to me??? Am I wrong?

    Can I send you just my Personal workbook and where will I find it?

    T

  13. #13
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Okay let's just see if we can clear up a couple of confusions. In your PDF that you sent at the top you have two userforms. Do you have two userforms?
    To make sure we get the code for the right userform, if you have more than one userform just click in a blank are of the userform, not the calendar or a button, just the form the part that has all the dots. Then right click and choose view code. When you do this the left box should say userform, don't touch it, leave it alone and go to the right button and choose initialize and add the code we talked about before. Save close everything down and reopen and see what happens.

    If this doesn't work then if you go to save as like you are going save the worksheet as something else you should be able to see the path to where it is now. Click go advanced the button next to save when you are posting on this site and then pick the paperclip in the new toolbox and you get and then you can upload your sheet to this site.
    Last edited by skywriter; 03-03-2015 at 06:41 PM.

  14. #14
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks for your continued support skywriter. Before I proceed, can I tidy up a bit.

    I fear that I have duplicates and probably should clean up before I proceed. I have put the details in the attached and perhaps you can advise if I should delete one. Interestingly, one form (called Calendar) displays with both the behaviours that are faulty (not selecting the current date and with 25/02/2015 greyed out) while the other (called UserForm1) displays with only one of the faults (not selecting current date)

    T
    Attached Files Attached Files

  15. #15
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Why don't you go to save as, then change the name of the file, save it to your desktop so you know where it is and upload it here, then I'll figure out what is wrong and we'll get you up and running. The original file can stay where it is. Don't worry about any of this, no need to apologize I really want to you help you and am more than happy to do it. If you have any sensitive information in your workbook just delete it. It should not be an issue since we are only concerned with getting the calendar(s) squared away.

  16. #16
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks skywriter

    Here is a copy of my "Personal.xlsb" file. I assume this is what you want.

    If there is a duplicate form, please remove.

    I assume I'll need to save any updated file to the correct location later (or else follow a detailed list of instructions from you on my local "Personal" workbook).

    T
    Attached Files Attached Files

  17. #17
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Okay the actual calendar on both forms is named, monthview1.
    Use this code.

    Private Sub UserForm_Initialize()
    
    MonthView1.Value = Date
    
    End Sub

  18. #18
    Registered User
    Join Date
    01-10-2015
    Location
    Dublin, Ireland
    MS-Off Ver
    Office 2013
    Posts
    29

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Thanks skywriter. We're getting there!

    As I said, I'm not a coder and don't have a good command of VBA, so I don't want to make a mess of this, so here is what I've done.

    1) I opened Excel (Book1)
    2) I unhid Personal workbook
    3) I went to Visual Basic in the Personal.xlsb workbook

    When I click on each of the forms and select view code, I get the following:-

    There appears to already be some "Initialise" code with the Calendar.Value = Date in it

    I would need instructions as to what to do and exactly where to add the code.

    T
    Attached Files Attached Files

  19. #19
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Talking Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Hi butterscotch,

    You want an excel calendar date picker in a floating VBA user form?

    And the default selected date is todays date & month?

    See attached. Is this what you were looking for?

    HTH


    (I didn't write this myself. The original code came from https://sites.google.com/site/e90e50...-control-class )
    Attached Files Attached Files
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  20. #20
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,251

    Re: Problem with a Excel Calendar Datepicker in a Floating VBA Userform

    Hi, I don't want to confuse things here and haven't read all the above thread, but Excel 2013 has a new calendar tool that may help you avoid this whole problem.
    See it at:
    http://www.vertex42.com/apps/minicalendar.html
    or read about Apps for Office where this Calendar tool is included at:
    http://theapprefinery.com/2013/04/20...-project-2013/
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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. Colours in a Calendar Datepicker in a Floating VBA Userform
    By butterscotch in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-25-2015, 03:32 PM
  2. Programming DatePicker in UserForm
    By yidode in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2015, 08:30 PM
  3. Issue on Calendar/DatePicker controls Compatiblity
    By SathishKumar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2013, 05:46 PM
  4. DatePicker calendar
    By fandreacci in forum Excel General
    Replies: 2
    Last Post: 04-09-2007, 04:55 PM
  5. UserForm as a tool bar/ floating options for excel sheet
    By Abraham.Olson@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2006, 11:55 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