When dealing with time values, even a simple arithmetic operations like addition can be difficult.
If you are calculating total working hours, and want to add overtime, you cannot simply add the time and minute values using arithmetic operators like +.
Instead, you can use a simple logic, or use the TIME function in Excel to add minutes to your total time. If you’re interested in advanced Excel, I have also included simple VBA codes to create functions.
- There are 60 minutes in an hour.
- A minute is equal to 1/60 hours.;
- There are 1440 minutes in one day.
- A minute in one day takes 1/1440 of the total time.
Add Minutes to Hours
You can add minute values in hours using simple logic, or you can create your very own function using the Visual Basics Editor.
Using Logic
As I mentioned before, there are 60 minutes in an hour. Before you add the minute value, you will have to first convert it into the hour format. We will use this logic to create basic formulas.
Step 1: Convert Minutes to Hour
In column A, I have the hour values and in column B, I have the minutes I wish to add. In column C, I entered the following formula and applied it to the rest of the column using Flash Fill:
=B2/60
Step 2: Sum Minutes and Hour
Now that our minute is in the hour format, we can add it to our total hour. In cell D2, I entered the following formula:
=A2+C2
Inserting a VBA Code
You can insert a VBA code to create a function that adds minutes into hours. Our function will be called TotalHours and you will have to insert the hours and the minutes you wish to add as the argument.
Go to the Developer tab and select Visual Basics. On the VBA editor, select Insert > Module. In the window, enter the following code:
Function TotalHour(Hour As Date, Minute As Date) As Date
Dim Total As Date
Total = Hour + (Minute / 60)
TotalHour = Total
End Function
On your spreadsheet, enter =TotalHour
and enter the hour followed by the minutes you wish to add.
Add Minutes to Total Time
There are two approaches to adding minutes to the total time. The first method uses a similar logic we used in the section above and the next one uses the TIME function.
Use Logic
Using the fact that there are 1440 minutes in one day, we can create a simple formula to add minutes to our time.
Say you’re calculating the time students finished taking a test after each took extra minutes. In column A, we have the time the test ended, and in column B, are the students’ extra time. Here’s a formula you can use to calculate the total time they took to finish their test:
=$A$2+(B2/1440)
Use the TIME Function
You can also use the TIME function to create a formula that adds minutes to your total time. The TIME function takes hours, minutes, and seconds for arguments. Here is how you can construct a formula using the TIME function:
=TIME(hour, minute, second)
Let’s use the same data set as we used before to add minutes using the TIME function.
=$A$2+TIME(0,B2,0)
As we’re only adding minutes to the total time, we entered 0 in the hour and second section.
Use VBA
You can also create a custom function to add minutes to your total time. The name of the function we’re about to create is called “AddMin” and it takes the total time, and minutes as its arguments.
From the Developer tab, select Visual Basic. Once the VBA editor opens, go to Insert > Module. Paste the following code in the window:
Function AddMin(Time As Date, Minute As Date) As Date
Dim Total As Date
Total = Time + (Minute / 1440)
AddMin = Total
End Function
Once you’ve pasted the code, go to your spreadsheet and enter =AddMin
on your spreadsheet. Then, enter your total time and the minutes you wish to add in the next section.
After you apply the formula, if your cell format is in General, you will have to change it to Time. Go to Home > General >Time.