Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have tried formatting the input fields as text but to no avail. When I step through it in the debugger it shows a double number which I presume is date conversion. I just want it to treat it as text and not convert it to a time/date.

Can somebody tell me how to prevent the conversion?

The text field has YY.MM.DD hh:mm:ss in text. I want to remove the seconds so I use:

Select.Value=MID(Select.Value,1,16) 

This does not work. I have put text in the field and it does truncate the last 3 positions.

share|improve this question
    
Please check the cell formatting to ensure that it is either "General" or "Formula" and not "Text" on your ref cell. –  skub Mar 25 '11 at 3:08
    
I think this is more of a question for stackoverflow.com (programming related). –  Steve Mar 25 '11 at 4:46
add comment

3 Answers

If you're using VBA, try using Format:

Select.Value=FORMAT(Select.Value,"YY.MM.DD hh:mm")
share|improve this answer
add comment

Try putting a single quote before the text field to force it to be considered as text.

share|improve this answer
add comment

It's not clear what you're trying to achieve with the time value, which affects the solutions proposed. However:

If you specifically want to do it through VBA, you can define a string variable and then pass it the time value:

strTextValue = cstr(format(selection.value,"YY.MM.DD HH:MM"))

You could also do this in the worksheet directly, for example:

=TEXT(range("A1"),"YY.MM.DD HH.MM"))
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.