Add time interval with VBA in Microsoft Excel

The VBA function DateAdd () adds a given number of minutes to a time:

Sub UhrzeitAddieren()
ThisWorkbook.Worksheets("Tabelle1").Activate
Range("E3").Value = DateAdd("n", _
Range("E2").Value, Range("E1").Value)
Range("E1,E3").NumberFormatLocal = "hh:mm"
End Sub

The DateAdd () function is used to add a time interval (second parameter) to a time specification (third parameter). The unit of the time interval is specified in the first parameter. There are the following possibilities:

yyyy: year
q: quarter
m: month
y: day of the year
d: day
w: day of the week
ww: week
h: hour
n: minute
s: second

In this example, a time interval of 90 minutes is added to the time 3:38 p.m., the result is 5:08 p.m. The two cells with the time information are also formatted appropriately.

Was the explanation to "Add time interval with VBA in Microsoft Excel"Helpful? Rate now:

Weitere Erklärungen zu Skriptsprachen