View Full Version : Solved: Input Box

12-07-2008, 11:13 AM
Hi Hello All,

I have an inputbox to allow user to input the date, then it will go into a excel for some calucation.

I set it up like this

UserForm1.datestart.Text = Format(Date, "dd-mm-yyyy")
UserForm1.dateend.Text = Format(Date, "dd-mm-yyyy")

But when the user input for example, 11/1/08

it will come into excel as an error, excel gets confuse with the year, 1908 and 2008.

Is there a way that I can force the user to input a 4-digit year instead?

Also, The User have to input a start and end date, when I set it up in this format, there is a default date on there and it changes everyday. For example right now, on both boxes, the date is 7/12/2008, but yesterday, they said 6/12/2008.

I want to make sure that the user inputs the date range before the run the command button for the calucation. Is there a way to generation a message box if they dont' enter in a new date?


Bob Phillips
12-07-2008, 11:19 AM
On the first part, are you saying you want 11/1/08 to be 1908, as it returns 2008 for me.

On the second, remove the default.

12-07-2008, 11:29 AM
oh no, i want it to be 2008, but if the user input 1/8/08, excel will not accept it as a date because it doesn't know what the year is (look at image).

I want to force the user to input the year in 4 - digit format.

12-07-2008, 11:38 AM
Rather than setting the inputbox to a format you need to set the output format like this...

MsgBox Format(TextBox1.Value, "dd/mm/yyyy")

then you can input it like 1/1/8 and it will come out in date format.

Hope this helps

12-07-2008, 11:44 AM
I did that but still get the same result, the problem is not that it did not put it in date format. it is in a date format but then excel doens't know if it's 1908 or 2008.

12-07-2008, 11:46 AM
I edited with an attatchment have a look.

Bob Phillips
12-07-2008, 12:30 PM
Cast it

Range("C1").Value = CDate(datestart.Text)

12-07-2008, 02:33 PM
it worked. :) thanks xld