|
-
Nov 25th, 2004, 12:26 PM
#1
Thread Starter
Hyperactive Member
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.
-
Nov 25th, 2004, 12:33 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Nov 29th, 2004, 03:52 AM
#3
New Member
You could try the calendar Control example posted here for free download
http://www.excel-it.com/workbookdown...s.htm#Calendar
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|