Time format for text box

  • Thread starter Thread starter hoyos
  • Start date Start date
H

hoyos

I'm struggling abit here. I have the following formatting code for a couple
of textboxes. But it's not working. Any suggestions?

Private Sub UserForm_Initialize()
TextBox78 = Format(Sheets("summary").Range("N21"), "hh:mm")
TextBox79 = Format(Sheets("summary").Range("N22"), "hh:mm")
End Sub
 
Hi,

That works fine but you have to have the time displayed in N21 and not just
formatted to show the date.

You can change the format of N21 & N22 at runtime if necessary to make it
display the time

Sheets("summary").Range("N21") = _
Format(Sheets("summary").Range("N21"), "hh:mm")

then your line

TextBox78.Text = Format(Sheets("summary").Range("N21"), "hh:mm")

Mike
 
Try this
TextBox78.Value = Format(Sheets("summary").Range("N21"), "hh:mm")
TextBox79.Value = Format(Sheets("summary").Range("N22"), "hh:mm")
 
Mike,
Thanks for replying. Do I put the first part of the formula in the sheet
code and the other in the textbox code?
Also the values in "hh:mm" are cumulative totals. It seems to go up to 24
hours and not beyond.
 
Mike,
I have managed to sort it out by:

Code in sheet "summary":

Range("n21").Value = Range("m21").Value
Range("n22").Value = Range("m22").Value

Code in userform:

TextBox79.Text = Sheets("summary").Range("N21").Text
TextBox78.Text = Sheets("summary").Range("N22").Text

Many thanks for your interest.
 
Back
Top