A combobox containing times returns a fraction (eg. I select "8:00" and it shows "0.3333")

bioplz

New Member
Joined
Dec 1, 2021
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
1645648799135.png

This is a good representation of my problem.
The value is pulled from a range of cells with a Custom format for h:mm. I am using this method, instead of a string, because I then want to subtract time out from time in.
This is mainly just a visual appearance issue, because I can multiply the value by 24 to get the actual time. It just looks terrible in the UserForm.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
So the problem is the "Time In" combo box? How are you populating that combobox? Can you please show any code you have related to these two comboboxes?
 
Upvote 0
So the problem is the "Time In" combo box? How are you populating that combobox? Can you please show any code you have related to these two comboboxes?
VBA Code:
Dim iCnt As Integer, totalTime As Integer
iCnt = fn_LastRow(trainSheet) + 1

If cbxTimeIn.Value <> "" And cbxTimeOut.Value <> "" Then
        totalTime = DateDiff("n", cbxTimeIn, cbxTimeOut)
    End If
   
    With trainSheet
        .Cells(iCnt, 1) = iCnt - 1 'txtID
        .Cells(iCnt, 2) = txtDate
        .Cells(iCnt, 3) = CStr(txtTrain)
        .Cells(iCnt, 4) = txtIssues
        .Cells(iCnt, 5) = cbxTimeIn
        .Cells(iCnt, 6) = cbxTimeOut
        .Cells(iCnt, 7) = (totalTime / 60) & " hrs"
        .Cells(iCnt, 8) = cbxParty
        .Cells(iCnt, 9) = cbxImpact
        .Cells(iCnt, 10) = cbxIsClosed
    End With

This is the code that I am using, and it currently works.

Also, I created a list in another worksheet and linked the list within the ComboBox's RowSource property.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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