Time in a userform textbox

Diving_Dan

Board Regular
Joined
Oct 20, 2019
Messages
161
So I have scoured google looking for the answer but I can't find exactly what I'm looking for.

I've got a userform to input data onto a worksheet. One of the textboxes is called textTimeAuthorised and the time gets put into this textbox in 24hr format. what I am trying to achieve is after the hours have been put in it automatically adds the colon for the time rather than having to manually input it.

Is this easily possible?

Thanks in advance

Dan
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try using the following TextBox_Change macro:
VBA Code:
Private Sub textTimeAuthorised_Change()
Dim cTxt As String
'
cTxt = Me.textTimeAuthorised.Text
If Len(cTxt) = 2 And Right(cTxt, 1) <> ":" Then
    Me.textTimeAuthorised = cTxt & ":"
End If
End Sub
Bye
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top