![]() |
input box
Hi, Can you advise me how to use an input box for Dates only. Id like
the user to Input a date only as dd/mm/yyyy. If anything else entered, or format wrong to tell user to try again. When date entered, to use that information to search the workbook for the date, also to have a msgbox apear to advise the month that has been entered. eg 20/09/2005 - you have entered SEPTEMBER as your month. I hope this is not asking to much. Regards robert |
input box
Hi Robert
How would you react to a program that rejected a perfectly normal date entry beause you didn't use / as separators or only entered a two digit year ? Don't be surprised if your users hate it and refuse to use it. By all means, I'd like the users to do only the right things too, but they won't, and we should assist them, not nag them. Please reconsider and rephrase your goal to "how can I ensure that only a valid date is entered into an inputbox ?". Here's a solution to that: Sub MakeDate() Dim D As Date Dim S As String Do S = InputBox("Your date:", , S) If S = "" Then Exit Sub Loop Until IsDate(S) D = DateValue(S) MsgBox "You entered " & Format(D, "dd/mm/yyyy") End Sub It accepts all common date formats according to the computer's regional settings. If you want it to accept an entry like 20092005 as well then you must do some additional coding, it is also worth doing. HTH. Best wishes Harald skrev i melding oups.com... Hi, Can you advise me how to use an input box for Dates only. Id like the user to Input a date only as dd/mm/yyyy. If anything else entered, or format wrong to tell user to try again. When date entered, to use that information to search the workbook for the date, also to have a msgbox apear to advise the month that has been entered. eg 20/09/2005 - you have entered SEPTEMBER as your month. I hope this is not asking to much. Regards robert |
input box
Harald
Thankyou for replying. A very good point, hadnt looked at it that way, taken on board though. Regards Robert |
All times are GMT +1. The time now is 05:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com