How to set Time Picker in excel user form to 24 hrs format?

cyrous0425

New Member
Joined
May 30, 2018
Messages
31
I tried the custom format and enter HHmm custom but when I run the macro after hitting the arrow it will displayed the date instead?


Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You'll need to set the Format property to dtpCustom, and then you can set the CustomFormat property to "HHmm". If you want to set these properties by code, assuming that the date and time picker control is named DTPicker1, try...

Code:
    With Me.DTPicker1
        .Format = dtpCustom
        .CustomFormat = "HHmm"
    End With

Hope this helps!
 
Last edited:
Upvote 0
dtpCustom will always display the calendar when the arrow is clicked, regardless of CustomFormat.

To get time only, set the Format property to dtpTime. Unfortunately, CustomFormat seems to be ignored and its format is always HH:mm:ss.
 
Upvote 0
I tried the dtpCustom but when I enter time on the time picker it becomes 0000. ​Same result with the code above.
 
Upvote 0
With dtpCustom, you can't select a time from the drop down menu. You can only select a date. So you would have to either tab to the date and time picker or click the first two digits so that the first two digits of the time are selected, and then you change the time. As an example, with the first two digits selected, you can either type 8:30 or first type 8, and then right-arrow to the next two digits to enter 30.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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