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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
hmmm never mind, the first thing I tried after I clicked post worked :rolleyes:

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

My brain's having a lazy day :LOL:
 
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,214,387
Messages
6,119,225
Members
448,877
Latest member
gb24

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