Combine Two Combobox Values To Create A Usable Time

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello all,

In my user form, I have two comboboxes. "uf1_hr" is a combobox that allows the user to select one of 24 values representing each hour of the day (0-23). The rowsource data is numerical. The second box, "uf1_min" (rowsource is text) allows the user to select 1 of 4 available increments of minutes (00, 15, 30, 45).

Using VBA how am I able to combine the selected values of each combobox to create a time value? I then wish to add the time value to the serial date held as a variable (t_date) in my code, but not sure how to do that in VBA either .

uf1_hr = 14
uf1_min = "00"
result = 14:00

date = 2-Jan-19
t_date = 43467 (1/2/19 12:00:00AM)
new t_date = 43467 + result (1/2/19 2:00:00PM)




Thank you all in advance!
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi there. Use this code:

new_t_date=t_date+((uf1_hr+(uf1_min/60))/24)
 
Last edited:
Upvote 0
Thank you! This worked wonderfully.
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,050
Members
449,206
Latest member
Healthydogs

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