Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there a Time picker?
I've read numerous posts on numerous boards about time formating, none of
which provide a direction to a true time picker. There are many a date/time picker references. It would seem to be the answere to many formating questions and would be a life saver to me. Anyone know of such a bit of code? Thanks Barry |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there a Time picker?
You could build one. In a fresh UserForm place a textbox (TextBox1) and try
pasting the below code ...Use up/down arrows to adjust the time Private Sub UserForm_Activate() Me.TextBox1 = Format(Now, "hh:mm") End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) 'Date and Time Picker Use down/up arrow to change date/time. Dim intPos As Integer, strType As String If KeyCode = 38 Or KeyCode = 40 Then intPos = Me.TextBox1.SelStart strType = Application.Lookup(intPos, Array(0, 3), Array("h", "n")) Me.TextBox1 = Format(DateAdd(strType, (39 - KeyCode), TextBox1), "hh:mm") KeyCode = 0 Me.TextBox1.SelStart = intPos End If End Sub 'For Date and Time picker Private Sub UserForm_Activate() Me.TextBox1 = Format(Now, "dd-mmm-yyyy hh:mm") End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) 'Date and Time Picker Use down/up arrow to change date/time. Dim intPos As Integer, strType As String If KeyCode = 38 Or KeyCode = 40 Then intPos = Me.TextBox1.SelStart strType = Application.Lookup(intPos, Array(0, 3, 7, 12, 15), _ Array("d", "m", "yyyy", "h", "n")) Me.TextBox1 = Format(DateAdd(strType, (39 - KeyCode), _ TextBox1), "dd-mmm-yyyy hh:mm") KeyCode = 0 Me.TextBox1.SelStart = intPos End If End Sub -- Jacob "Barry" wrote: I've read numerous posts on numerous boards about time formating, none of which provide a direction to a true time picker. There are many a date/time picker references. It would seem to be the answere to many formating questions and would be a life saver to me. Anyone know of such a bit of code? Thanks Barry . |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Is there a Time picker?
Jacob Skaria,
Using the below code you posted, I have been able to achieve a portion of the job. I am somewhat confused as to how to get the selected time from the user form to the cell selected on the sheet. As you may have guessed I'm a beginner here so be kind, I do want to learn. You could build one. In a fresh UserForm place a textbox (TextBox1) and try pasting the below code ...Use up/down arrows to adjust the time Private Sub UserForm_Activate() Me.TextBox1 = Format(Now, "hh:mm") End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) 'Date and Time Picker Use down/up arrow to change date/time. Dim intPos As Integer, strType As String If KeyCode = 38 Or KeyCode = 40 Then intPos = Me.TextBox1.SelStart strType = Application.Lookup(intPos, Array(0, 3), Array("h", "n")) Me.TextBox1 = Format(DateAdd(strType, (39 - KeyCode), TextBox1), "hh:mm") KeyCode = 0 Me.TextBox1.SelStart = intPos End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date and Time Picker - two an issue? | Excel Discussion (Misc queries) | |||
pop up Date time picker | Excel Discussion (Misc queries) | |||
Date Time Picker | Excel Discussion (Misc queries) | |||
Date and Time Picker | Excel Discussion (Misc queries) | |||
Date and Time Picker Control | Excel Discussion (Misc queries) |