Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date and Time Picker - two an issue? Don Excel Discussion (Misc queries) 0 February 12th 10 02:48 PM
pop up Date time picker Mike Excel Discussion (Misc queries) 3 November 17th 06 08:00 PM
Date Time Picker Mike Excel Discussion (Misc queries) 0 November 16th 06 04:36 AM
Date and Time Picker DAN J Excel Discussion (Misc queries) 2 September 21st 06 11:47 PM
Date and Time Picker Control Andy T Excel Discussion (Misc queries) 0 January 6th 05 04:09 PM


All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"