Yes, you can add minutes to a time in Excel VBA in one line. Excel stores times as fractions of a day, so adding minutes means adding minutes / 1440 to the time value: Range("A1").Value = Range("A1").Value + (30 / 1440) adds 30 minutes. Alternatively, you can use the DateAdd function: DateAdd("n", 30, someTime). Both approaches work in any modern version of Excel and require no special setup beyond enabling the VBA editor.
What You'll Need
- Excel (any version from Excel 2007 onward works fine; the VBA editor is included)
- A workbook saved as a macro-enabled file (.xlsm) if you want to keep the code
- Basic familiarity with opening the VBA editor (Alt + F11)
- A cell or variable holding a valid Excel time value
Step-by-Step
- Open the VBA editor. Press Alt + F11 in Excel, or go to the Developer tab and click Visual Basic. If the Developer tab is missing, enable it via File > Options > Customize Ribbon and tick Developer in the right-hand list.
- Insert a module. In the VBA editor menu, choose Insert > Module. A blank code window opens.
- Write a simple procedure. Type the following:
Sub AddMinutesToTime()
Dim t As Date
t = Range("A1").Value
Range("B1").Value = t + (45 / 1440)
End Sub
This reads the time from cell A1 and writes the time plus 45 minutes into B1. The number 1440 is the number of minutes in a day (24 × 60), which is how Excel converts minutes into its day-fraction time format.
- Or use DateAdd instead. Many people find this more readable:
Sub AddMinutesToDateAdd()
Dim t As Date
t = Range("A1").Value
Range("B1").Value = DateAdd("n", 45, t)
End Sub
The interval string "n" means minutes ("m" is months, so VBA uses "n" for minutes). Other useful intervals: "s" for seconds, "h" for hours, "d" for days.
- Make the minutes a parameter. For a reusable version, pass the minutes in:
Function AddMinutes(startTime As Date, mins As Long) As Date
AddMinutes = startTime + (mins / 1440)
End Function
You can then call it from another macro (Range("B1").Value = AddMinutes(Range("A1").Value, 45)) or use it directly in a worksheet formula: =AddMinutes(A1, 45).
- Run the macro. Press F5 with the cursor inside the Sub, or close the editor and run it from Developer > Macros (or press Alt + F8, select the macro, click Run).
- Format the result cell as a time. Right-click the result cell, choose Format Cells, and pick a Time format such as 13:30. If the cell shows a decimal like 0.55, it is formatted as a number, not a time.
- Save correctly. Save the workbook as .xlsm (Excel Macro-Enabled Workbook) so the code is kept. Saving as .xlsx will discard the macros.
Common Mistakes
- Adding minutes directly without dividing by 1440.
t + 45adds 45 days, not 45 minutes. Always divide the minutes by 1440. - Using "m" in DateAdd for minutes. "m" means month. Minutes must be "n".
- Adding minutes to a text string. If the cell contains text like "9:00 AM" stored as text (often left-aligned), the math fails or gives wrong results. Convert first with
CDate(Range("A1").Value)or fix the cell's data type. - Forgetting midnight rollover. Adding minutes to 23:50 correctly produces a time after midnight, but the underlying value also carries a date. If you only want the time, format the cell to show time only, or strip the date with
Int()logic if needed. - Not formatting the output. Writing a time into an unformatted General cell may display a decimal fraction.
Tips
- For adding hours, divide by 24 instead of 1440; for seconds, divide by 86400.
DateAdd("n", -30, t)subtracts 30 minutes, since negative values work in both methods.- Use
TimeSerial(hour, minute, second)to build a time from parts when you don't have one already. - To apply the operation across a range, loop through cells or use a formula; a simple
For Each cell In Range("A1:A10")loop with the addition inside works well. - Declare time variables as
Date, notString, so VBA treats the values correctly.
Troubleshooting
- The result shows a decimal like 0.65. The cell is formatted as a number. Apply a Time format via Format Cells.
- Type mismatch error (runtime error 13). The source cell is empty or contains text. Check that A1 holds a real time, or wrap the read in
CDate()and handle errors withOn Errorif the input might be invalid. - The result is off by a whole day. You added raw minutes instead of minutes / 1440, or added days somewhere in the chain. Recheck the division.
- Macros won't run. Macros may be disabled. When you open the file, click Enable Content in the security bar, or review settings under File > Options > Trust Center > Trust Center Settings > Macro Settings. Only enable macros in files you trust.
- The macro vanished after saving. You saved as .xlsx. Save as .xlsm instead.
- Times after midnight look wrong. The value now includes the next day's date. Format the cell with a time-only format (hh:mm) to display it cleanly.
Frequently Asked Questions
Why divide by 1440?
Excel stores one day as the number 1, so one minute equals 1/1440 of a day (24 hours × 60 minutes). Dividing minutes by 1440 converts them into Excel's day-fraction format.
Is DateAdd or the division method better?
Both give identical results. DateAdd is more readable and self-documenting; the division method is slightly more compact. Use whichever your team finds clearer.
Can I subtract minutes?
Yes. Use a negative number: DateAdd("n", -15, t) or t - (15 / 1440).
What happens if the result goes past midnight?
Excel handles it automatically: the time rolls over to the next day and the underlying value gains one day. Format the cell as time-only if you don't want the date shown.
Can I do this without VBA?
Yes. In a worksheet formula, use =A1 + TIME(0, 45, 0) or =A1 + 45/1440. VBA is only needed when the addition must happen inside a macro or automated workflow.
How do I add minutes to the current time?
Use Now or Time: DateAdd("n", 30, Now) or Time + 30 / 1440. Now includes the date; Time is time only.