UserForm TextBox - Format as minutes only

Alan_P

Well-known Member
Joined
Jul 8, 2014
Messages
596
Hi Guys,

I'm absolutely stumped on what I thought would be very very easy and could do with some help please! :confused:

I've got a time value in cell A1, say 10:45. On my UserForm I've got two TextBoxes, in the first one I want to show the hour value - "10", in the second one I want to show the minute value - "45"

The hour value is easy:
Code:
TextBox1.Value = Format(Cells(1, 1).Value, "HH")

But I can't for the life of me figure out how to get the minute value in a textbox!

Any help would be very much appreciated!
Thanks,
Alan.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
hmmm never mind, the first thing I tried after I clicked post worked :roll:

Code:
TextBox1.Value = Right(Format(Cells(1, 1).Value, "HH:MM"), 2)

My brain's having a lazy day :laugh:
 
Upvote 0
How about

Code:
TextBox1.Value = Hour(Range("A1").Value)
TextBox2.Value = Minute(Range("A1").Value)
 
Upvote 0
How about

Code:
TextBox1.Value = Hour(Range("A1").Value)
TextBox2.Value = Minute(Range("A1").Value)
The OP should definitely be using those functions. Just pointing out for those who do not mind using the square bracket version of Evaluate (when the cell address is fixed and non-changing), there is this compact version of your code lines...

Code:
 TextBox1.Value = Hour([A1])
 TextBox2.Value = Minute([A1])
 
Upvote 0

Forum statistics

Threads
1,222,180
Messages
6,164,419
Members
451,893
Latest member
csmithbuffalo

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