bitterpill
bitterpill

Reputation: 3

Excel VBA InputBox value is not a date

I have a user input box where you type in a string, annoyingly this string looks like a date 00/00/0000 and excel reformats it as such. When the value can't be a date ex. 18/19/4561 (month can't be 18 or 19) it displays it correctly. But whenever it can be seen as a possible date it switches things around.

I've tried setting the value as a string rather than nothing but excel still changes it when putting it in the page.

When I try manually inputting it in the cell or equal the values from a manually entered cell it works fine.

But whenever I get it from the inputbox it messes with it. Even when I hard code the string to a variable (x = "05/06/4564") it switches things around.

How do I force excel to leave the string as is?

Upvotes: 0

Views: 290

Answers (1)

joehanna
joehanna

Reputation: 1489

Prefix the value with a single apostrophe and Excel will interpret it as a string.

Eg '18/19/4561

Also, have you tried setting the cell format to Text

Upvotes: 2

Related Questions