I am recently posted a thread about some trouble I was having formatting cells on my spreadsheet to display time. The user enters the start time of a meeting on a form. The hour and minutes are placed in a text box in the format 11:00. Then they select radio buttons for AM/PM. The problem arose when I tried to put this information into the spreadsheet. Instead of displaying the time in h:mm AM/PM format it came out as a big, ugly, nasty decimal number. This problem was solved, with a little help from members of this forum, as follows:
.Cells(3, 4) = Trim(txtTime.Text) & IIf(optAM, " AM", " PM")
.Cells(3, 4).NumberFormat = "h:mm AM/PM"
Now the problem I have is reading the cells and converting the time back to the user form for editing. It will not read the time as a text string which I can then manipulate, but instead the big, hairy, nasty 0.458333333333333. It even cuts off my AM/PM when I read it in. How can I read the time into a variable in a way that I can extract the information that I want?
.Cells(3, 4) = Trim(txtTime.Text) & IIf(optAM, " AM", " PM")
.Cells(3, 4).NumberFormat = "h:mm AM/PM"
Now the problem I have is reading the cells and converting the time back to the user form for editing. It will not read the time as a text string which I can then manipulate, but instead the big, hairy, nasty 0.458333333333333. It even cuts off my AM/PM when I read it in. How can I read the time into a variable in a way that I can extract the information that I want?