Userform textbox - convert minutes to hours and minutes

RobbieC

Active Member
Joined
Dec 14, 2016
Messages
376
Office Version
  1. 2010
Platform
  1. Windows
Hi there, I have a userform with 2 textboxes. One is called 'Time and one is called 'mins'

I'm trying to get the 'Time' textbox to reflect 'mins' textbox in hours and mins ie:

mins = 345 therefore Time = 5:45

I thought I could use something along the lines of:

Code:
Sub mins_Change()
Dim minsVar
minsVar = Me.mins.Value
Me.Time.Value = Format(minsVar, "h:mm")
End Sub

or

Code:
Sub mins_Change()
Dim minsVar
minsVar = Me.mins.Value
Me.Time.Value = Application.WorksheetFunction.text(minsVar, "h:mm")
End Sub

but both just change Time to 0:00

If you can point me in the right direction, I'd be very happy

Thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi there, I have a userform with 2 textboxes. One is called 'Time and one is called 'mins'

I'm trying to get the 'Time' textbox to reflect 'mins' textbox in hours and mins ie:

mins = 345 therefore Time = 5:45

I thought I could use something along the lines of:

Code:
Sub mins_Change()
Dim minsVar
minsVar = Me.mins.Value
Me.Time.Value = Format(minsVar[B][COLOR="#FF0000"] / 1440[/COLOR][/B], "h:mm")
End Sub
Add what I show in red above (1440 is the number of minutes in a 24-hour day).
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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