Sum minutes to Combobox

Ramses28

New Member
Joined
May 18, 2018
Messages
10
I want to sum 10 minutes to a combobox (the combobox is filled with an hour in format "hh:mm").

I used the code:

ComboBox2.value = (Format(ComboBox2.Value, "hh:mm")) + (Format("00:10", "hh:mm"))

but it doesn't sum the 10 minutes and i don't understand why?

Thanks in advance
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
Try this

Code:
Private Sub CommandButton1_Click()
ComboBox2.Value = TimeValue(ComboBox2.Value) + TimeValue("00:10")
End Sub
 

Ramses28

New Member
Joined
May 18, 2018
Messages
10
Thats it!!
The combobox changes to the format to "10:10:00 AM". Is it possible to convert to just "10:10"??
Thanks Yongle
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
Try this

Code:
Private Sub CommandButton1_Click()
    With ComboBox2
        .Value = TimeValue(.Value) + TimeValue("00:10")
        .Value = Format(.Value, "hh:mm")
    End With
End Sub
 

Ramses28

New Member
Joined
May 18, 2018
Messages
10

ADVERTISEMENT

Doesn't work.
Returns an error: "invalid property value".
Don't now why.
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
Method tested here
- it works (both userform and on-sheet embedded active-x)

Where is your combobox?
 
Last edited:

Ramses28

New Member
Joined
May 18, 2018
Messages
10
Figured out the issue.
The combobox style was wrong. it was defined as dropdownlist. i changed it to combo and the code works perfectly.
Thanks a lot!
 

Forum statistics

Threads
1,136,339
Messages
5,675,193
Members
419,553
Latest member
hanahass

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
Top