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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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