0

I have a table with data validation list set for the user to choose from a drop down menu a list of times (formatted as h:mm AM/PM), which is then read in VBA to compare the time to another. The data validation seems to have converted the times to a string, so right now it seems I have to just use a block of code to convert that back to a double through VBA so I can do the comparison.

Is there a better method that I'm missing?

What I'm trying to do is let the user choose a time, then on a table with all the times listed, I run a comparison to find the proper cell and put the info in.

2
  • Questions about code should ideally include code... There are no "types" in a validation list though - everything is a string. Commented May 27, 2016 at 18:32
  • Sorry about that, I don't really have a question about the code itself (yet). I wanted to see if I'm going about this in a completely retarded manner before I tackled trying to do conversions back and forth Commented May 27, 2016 at 18:57

1 Answer 1

0

I think is better to work Date type. I Show you as you can convert a string to a date. This way your problem is solved.

 Sub teste()
    Dim time As Date
    time = TimeValue("9:00 PM")
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.