# Sum Combo Boxes to get total time worked

#### sacastiglia

##### New Member
Hello,

I will be so grateful to get this solved. I have a user form (UserForm1) that I need to calculate total amount of hours worked in a text box from the values in the combo boxes below. All values are time based (i.e. 7:00 am, 7:00 pm; not military time)

ComboBox2 = Drive Start Time
ComboBox3 = On Site Time
ComboBox4 = Break Start Time
ComboBox5 = Break End Time
ComboBox6 = Off Site Time
ComboBox7 = Drive End Time

I have a formula in the timesheet to calculate this but that won't happen until the user form is loaded into the spreadsheet. I would like to have this feature available to the users so if a mistake is made, they can correct it before loading it onto the timesheet.

The code I have for the initialize user form is as follows:

HTML:
``````Private Sub UserForm_Initialize()
OptionButton1.Value = True
OptionButton2.Value = True
OptionButton3.Value = True
OptionButton4.Value = True
OptionButton5.Value = True
OptionButton12.Value = True
OptionButton13.Value = True
OptionButton14.Value = True
OptionButton9.Value = True
OptionButton10.Value = True
TextBox2.Value = ""
TextBox15.Value = (Val(ComboBox3.Value) + Val(ComboBox2.Value)) * 24
With ComboBox1
.CLEAR
.AddItem "Prevailing Wage - Non Mgr"
End With
With ComboBox2
.CLEAR
End With
With ComboBox3
.CLEAR
End With
With ComboBox4
.CLEAR
End With
With ComboBox5
.CLEAR
End With
With ComboBox6
.CLEAR
End With
With ComboBox7
.CLEAR

End With
End Sub``````

Thank you

### Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
But what are the calculations that you wanna do exactly?

But what are the calculations that you wanna do exactly?

I would like them to calculate the total hours worked less the half hour break.

I have Drive hours calculated on the workbook with the following formula

J6 is the On Site Time
I6 is the Drive Start Time
N6 is the Drive End Time
M6 is the Off Site Time
=SUM((J6-I6)*24)+SUM(N6-M6)*24

Site hours are calculated with the following formula:

M6 is the Off Site Time
J6 is the On Site Time
L6 is the Break End Time
K6 is the Break Start Time

=SUM((M6-J6)*24)-SUM(L6-K6)*24

So the total time worked would be the Drive Start to the Drive End less lunch.

Is it possible to do this same calculation with the Combo boxes.

I have a text box whose value is the total hours. I have tried to add a Command Button that loads the Time Cells but every time I click on it, it clears the user form. I would like for our Technicians to Check their total hours before committing to unloading the entire form. I am not sure what code I should use to prevent resetting the form after it is unloaded. I do want the form reset once the Technician commits to unload the entire form.

Any help would be greatly appreciated.

Replies
4
Views
497
Replies
5
Views
332
Replies
3
Views
226
Replies
4
Views
292
Replies
1
Views
159

1,219,570
Messages
6,149,045
Members
450,853
Latest member
xtiinctt

### 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.

### Which adblocker are you using?

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

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