![]() |
Format a Userform textbox to Military time
I have a user form with 5 textboxes linked to cells. I can't seem to get the
textboxes to show the entry in Military time. It keeps changing to decimal. The time shows up correctly in the cell. any help would be greatly appreciated. Christy ;) |
Format a Userform textbox to Military time
Try something like:
Private Sub UserForm_Initialize() Dim ws As Worksheet Set ws = ActiveSheet TextBox1.Text = Format$(ws.Range("A1"), "H:mm") Set ws = Nothing End Sub Note: the capital 'H' in the format string is important. If you use a lowercase 'h' then you'll get a 12-hour clock value. |
Format a Userform textbox to Military time
Thanks Nick, I will try that!
Christy ;) "Nick Hebb" wrote: Try something like: Private Sub UserForm_Initialize() Dim ws As Worksheet Set ws = ActiveSheet TextBox1.Text = Format$(ws.Range("A1"), "H:mm") Set ws = Nothing End Sub Note: the capital 'H' in the format string is important. If you use a lowercase 'h' then you'll get a 12-hour clock value. |
All times are GMT +1. The time now is 09:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com