Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Option Explicit
Sub testme() Dim myDate As Variant myDate = InputBox(Prompt:="enter a date") If Trim(myDate) = "" Then Exit Sub 'user hit cancel End If If IsDate(myDate) Then myDate = CDate(myDate) Else MsgBox "not a date" Exit Sub End If End Sub You might want to take a look at Ron de Bruin's site for some tips/code/free calendar control: http://www.rondebruin.nl/calendar.htm If the user enters 02/03/04, what date do you expect back. (The calendar control may make it easier to decipher.) ArthurJ wrote: Using the InputBox (either Excel's method or VBA's function), I'd like the user to specify a date. But how can I tell if the user has clicked cancel? Second question: the Excel InputBox allows me to specify the data type. That's good. But it isn't quite narrow enough (merely 'number' rather than 'date'). Is there a way I can tighten up the data type to 'date'? Art -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
InputBox | Excel Discussion (Misc queries) | |||
inputbox | Excel Discussion (Misc queries) | |||
Inputbox and Application.InputBox | Excel Programming | |||
inputbox help | Excel Programming | |||
inputbox | Excel Programming |