Results 1 to 3 of 3

Thread: Date Selection UserForm in Excel VBA

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Resolved Date Selection UserForm in Excel VBA

    I'm trying to create a spreadsheet that allows you to define maintenance schedules for lanscape management work.

    The items that are going to be in the maintenance schedule generally occur yearly (e.g. turf refurbishment) or monthly (e.g. litter collection, grass cutting).

    I want to be able to have a dialog box appear that allows the user to specify for the yearly items what date of the year maintenance occurs (dd/mm/yyyy) or for the monthly items what date of the month maintenance occurs (dd/mm).

    Does anyone have any ideas about how best to achieve this? I thought about have 3 textboxes with spinnerbuttons bound to them so the user can create their own dates by selected the dd/mm/yyyy components seperately, or maybe 3 drop down lists that do the same thing.

    However.......if I did this, how would I stop dates being created that don't actually exist? E.g. 30th February, 31st September etc?

    I suppose I could write an error handling routine for each month selected and check to see if the days selected for that month fall within an acceptable range e.g. range for September would be:

    Range
    Septmember_Days >= 1
    September_Days < 31

    The user would need to click an 'OK' button once they have the date entered as they want it, and then the date from the textboxes is passed to a variable, or perhaps stored in a cell somewhere. Whatever, as long as it's retrievable later on in the application.

    But is there a better way of doing this? I would have thought Excel would have some kind of built-in calandar type function to do this sort of thing but I can't seem to locate it if it does.

    Cheers
    -Rob
    Last edited by TheRobster; Nov 25th, 2004 at 05:57 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    There is a DateTimePicker control in the Toolbox. Its exactly like the
    dtp in VB. It will not allow a user to enter an invalid date.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    New Member
    Join Date
    Nov 2004
    Location
    UK
    Posts
    2
    You could try the calendar Control example posted here for free download

    http://www.excel-it.com/workbookdown...s.htm#Calendar
    HTH

    Roy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width