inputbox date format

P

PBcorn

thismonth = CDate(Application.InputBox(prompt:="Enter the Current Month",
Title:="Select Date"))

i want the user to be able to input in mmm-yy format, e.g may-09. But when
may-09 is entered, for example, thismonth becomes 09/05/09. Why and how can i
get around this?
 
J

Jacob Skaria

CDate converts this to a date in your system date time format.. You can use
the Format function to display/use this...If you are looking at putting this
back to a cell; then input to the cell as it is and format the cell to mmm-yy

Dim thismoonth As Variant

thismonth = CDate(Application.InputBox(prompt:="Enter the Current Month", _
Title:="Select Date", Default:=Format(Date, "mmm-yy")))
MsgBox Format(thismonth, "mmm-yy")

If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top