ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform Defaults Text Box with Time (https://www.excelbanter.com/excel-programming/369155-userform-defaults-text-box-time.html)

Matt[_39_]

Userform Defaults Text Box with Time
 
I'm using a userform for data entry purposes and it is set to call the
values currently in the cells to display in the text boxes. Example:
TextBox1 relates to the cell in row 2 column 4

Private Sub UserForm_Activate()
Me.Time.Text = Worksheets("Data").Cells(2, 4).Value
End Sub

My problem is that the value in row 2 column 4 is a time and on the
form it displays a decimal value

is there a way to make my text box display this number as a time
instead?


Matt[_39_]

Userform Defaults Text Box with Time
 
I forgot to mention that it will not always be a time (sometimes it
will be text explaining why the event didn't happen rather than the
time it did happen)


Ardus Petus

Userform Defaults Text Box with Time
 
Try:
Me.Time.Text = Format(Worksheets("Data").Cells(2, 4).Value,"dd/mm/yyyy")

HTH
--
AP


"Matt" a écrit dans le message de news:
...
I'm using a userform for data entry purposes and it is set to call the
values currently in the cells to display in the text boxes. Example:
TextBox1 relates to the cell in row 2 column 4

Private Sub UserForm_Activate()
Me.Time.Text = Worksheets("Data").Cells(2, 4).Value
End Sub

My problem is that the value in row 2 column 4 is a time and on the
form it displays a decimal value

is there a way to make my text box display this number as a time
instead?




Matt[_39_]

Userform Defaults Text Box with Time
 
Format is good, but "dd/mm/yyyy" gives me it as days and not times

whats the format for times? 12 hour clock including AM/PM

Ardus Petus wrote:
Try:
Me.Time.Text = Format(Worksheets("Data").Cells(2, 4).Value,"dd/mm/yyyy")

HTH
--
AP


"Matt" a écrit dans le message de news:
...
I'm using a userform for data entry purposes and it is set to call the
values currently in the cells to display in the text boxes. Example:
TextBox1 relates to the cell in row 2 column 4

Private Sub UserForm_Activate()
Me.Time.Text = Worksheets("Data").Cells(2, 4).Value
End Sub

My problem is that the value in row 2 column 4 is a time and on the
form it displays a decimal value

is there a way to make my text box display this number as a time
instead?



Mark Lincoln

Userform Defaults Text Box with Time
 
Try this:

Private Sub UserForm_Activate()
Me.Time.Text = Worksheets("Data").Cells(2, 4).Text
End Sub

Matt wrote:
I'm using a userform for data entry purposes and it is set to call the
values currently in the cells to display in the text boxes. Example:
TextBox1 relates to the cell in row 2 column 4

Private Sub UserForm_Activate()
Me.Time.Text = Worksheets("Data").Cells(2, 4).Value
End Sub

My problem is that the value in row 2 column 4 is a time and on the
form it displays a decimal value

is there a way to make my text box display this number as a time
instead?



Matt[_39_]

Userform Defaults Text Box with Time
 
That works, thanks!

Also found:

Private Sub UserForm_Activate()
Me.Time.Text = Format(Worksheets("Data").Cells(2, 4).Value, "h:mm
AM/PM")
End Sub

both work

Mark Lincoln wrote:
Try this:

Private Sub UserForm_Activate()
Me.Time.Text = Worksheets("Data").Cells(2, 4).Text
End Sub

Matt wrote:
I'm using a userform for data entry purposes and it is set to call the
values currently in the cells to display in the text boxes. Example:
TextBox1 relates to the cell in row 2 column 4

Private Sub UserForm_Activate()
Me.Time.Text = Worksheets("Data").Cells(2, 4).Value
End Sub

My problem is that the value in row 2 column 4 is a time and on the
form it displays a decimal value

is there a way to make my text box display this number as a time
instead?




All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com